From 8c10617259cfd35edc7ddc04e7e3da5a80aa506c Mon Sep 17 00:00:00 2001 From: Franco Montenegro Date: Tue, 28 Jun 2022 12:25:20 -0300 Subject: [PATCH 1/5] Use a retry counter/limit to fetch thumbnails. (#7618) --- ui/component/channelThumbnail/view.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/component/channelThumbnail/view.jsx b/ui/component/channelThumbnail/view.jsx index cc293a458..b1c8e8e1d 100644 --- a/ui/component/channelThumbnail/view.jsx +++ b/ui/component/channelThumbnail/view.jsx @@ -50,6 +50,7 @@ function ChannelThumbnail(props: Props) { setThumbUploadError, ThumbUploadError, } = props; + const [retries, setRetries] = React.useState(3); const [thumbLoadError, setThumbLoadError] = React.useState(ThumbUploadError); const shouldResolve = !isResolving && claim === undefined; const thumbnail = rawThumbnail && rawThumbnail.trim().replace(/^http:\/\//i, 'https://'); @@ -58,6 +59,15 @@ function ChannelThumbnail(props: Props) { const channelThumbnail = thumbnailPreview || thumbnail || defaultAvatar; const isGif = channelThumbnail && channelThumbnail.endsWith('gif'); const showThumb = (!obscure && !!thumbnail) || thumbnailPreview; + const avatarSrc = React.useMemo(() => { + if (retries <= 0) { + return defaultAvatar; + } + if (!thumbLoadError) { + return channelThumbnail; + } + return defaultAvatar; + }, [retries, thumbLoadError, channelThumbnail, defaultAvatar]); // Generate a random color class based on the first letter of the channel name const { channelName } = parseURI(uri); @@ -100,9 +110,10 @@ function ChannelThumbnail(props: Props) { { + setRetries((retries) => retries - 1); if (setThumbUploadError) { setThumbUploadError(true); } else { -- 2.45.2 From 6aa914ab14f4eb425978cb595a97404c10cc482d Mon Sep 17 00:00:00 2001 From: ByronEricPerez Date: Tue, 28 Jun 2022 13:57:52 -0300 Subject: [PATCH 2/5] Added checkbox to enable/disable background --- static/app-strings.json | 2 ++ ui/component/settingAppearance/index.js | 1 + ui/component/settingAppearance/view.jsx | 11 ++++++++++- ui/component/wallpaper/index.js | 20 ++++++++------------ ui/component/wallpaper/view.jsx | 6 ++++-- ui/constants/settings.js | 1 + 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index 6576939b8..a8e046c71 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -2312,5 +2312,7 @@ "Free --[legend, unused disk space]--": "Free", "Top content in %language%": "Top content in %language%", "Apply": "Apply", + "24-hour clockss": "24-hour clockss", + "background": "background", "--end--": "--end--" } diff --git a/ui/component/settingAppearance/index.js b/ui/component/settingAppearance/index.js index 45d1b44e8..40b79f685 100644 --- a/ui/component/settingAppearance/index.js +++ b/ui/component/settingAppearance/index.js @@ -5,6 +5,7 @@ import { makeSelectClientSetting } from 'redux/selectors/settings'; import SettingAppearance from './view'; const select = (state) => ({ + background: makeSelectClientSetting(SETTINGS.BACKGROUND)(state), clock24h: makeSelectClientSetting(SETTINGS.CLOCK_24H)(state), searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state), hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state), diff --git a/ui/component/settingAppearance/view.jsx b/ui/component/settingAppearance/view.jsx index 9425ec436..634f74a87 100644 --- a/ui/component/settingAppearance/view.jsx +++ b/ui/component/settingAppearance/view.jsx @@ -12,6 +12,7 @@ import ThemeSelector from 'component/themeSelector'; import homepages from 'homepages'; type Props = { + background: boolean, clock24h: boolean, searchInLanguage: boolean, hideBalance: boolean, @@ -20,7 +21,7 @@ type Props = { }; export default function SettingAppearance(props: Props) { - const { clock24h, searchInLanguage, hideBalance, setClientSetting, setSearchInLanguage } = props; + const { clock24h, background, searchInLanguage, hideBalance, setClientSetting, setSearchInLanguage } = props; return ( <> @@ -63,6 +64,14 @@ export default function SettingAppearance(props: Props) { checked={clock24h} /> + + setClientSetting(SETTINGS.BACKGROUND, !background)} + checked={background} + /> + { - if (props.uri && (props.uri.indexOf('@') !== -1 || props.uri.indexOf('#') !== -1)) { - return { - cover: makeSelectCoverForUri(props.uri)(state), - avatar: makeSelectAvatarForUri(props.uri)(state), - }; - } else return {}; -}; -*/ +const select = (state) => ({ + background: makeSelectClientSetting(SETTINGS.BACKGROUND)(state), +}); -export default connect()(Wallpaper); +const perform = {}; + +export default connect(select, perform)(Wallpaper); diff --git a/ui/component/wallpaper/view.jsx b/ui/component/wallpaper/view.jsx index 3b21a735f..85da51513 100644 --- a/ui/component/wallpaper/view.jsx +++ b/ui/component/wallpaper/view.jsx @@ -8,10 +8,11 @@ type Props = { // cover: ?string, // avatar: ?string, reset: ?boolean, + background: ?boolean, }; const Wallpaper = (props: Props) => { - // const { cover, avatar } = props; + const { background } = props; /* if (avatar) { @@ -227,12 +228,13 @@ const Wallpaper = (props: Props) => { }} /> */ + return ( <>
diff --git a/ui/constants/settings.js b/ui/constants/settings.js index a56b28fc3..8b8bfb713 100644 --- a/ui/constants/settings.js +++ b/ui/constants/settings.js @@ -14,6 +14,7 @@ export const THEME = 'theme'; export const THEMES = 'themes'; export const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled'; export const CLOCK_24H = 'clock_24h'; +export const BACKGROUND = 'background'; export const AUTOPLAY_MEDIA = 'autoplay'; export const AUTOPLAY_NEXT = 'autoplay_next'; export const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled'; -- 2.45.2 From 15fdbe2ae6fa80510607f65d88a54728f0667136 Mon Sep 17 00:00:00 2001 From: ByronEricPerez Date: Tue, 28 Jun 2022 14:14:35 -0300 Subject: [PATCH 3/5] bug fix in enable disable button --- static/app-strings.json | 1 + ui/component/wallpaper/view.jsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/static/app-strings.json b/static/app-strings.json index a8e046c71..86e065406 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -2314,5 +2314,6 @@ "Apply": "Apply", "24-hour clockss": "24-hour clockss", "background": "background", + "Disable background": "Disable background", "--end--": "--end--" } diff --git a/ui/component/wallpaper/view.jsx b/ui/component/wallpaper/view.jsx index 85da51513..11ef316ba 100644 --- a/ui/component/wallpaper/view.jsx +++ b/ui/component/wallpaper/view.jsx @@ -234,7 +234,7 @@ const Wallpaper = (props: Props) => {
-- 2.45.2 From 97920a6bf073911acae2e44d3e00007f13c7376f Mon Sep 17 00:00:00 2001 From: ByronEricPerez Date: Tue, 28 Jun 2022 14:26:17 -0300 Subject: [PATCH 4/5] small fix in translation --- static/app-strings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/app-strings.json b/static/app-strings.json index 86e065406..7fa95843d 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -2312,7 +2312,7 @@ "Free --[legend, unused disk space]--": "Free", "Top content in %language%": "Top content in %language%", "Apply": "Apply", - "24-hour clockss": "24-hour clockss", + "24-hour clock": "24-hour clock", "background": "background", "Disable background": "Disable background", "--end--": "--end--" -- 2.45.2 From b77ae9b0eaf3914ac3159f214dfd58d06d436836 Mon Sep 17 00:00:00 2001 From: ByronEricPerez Date: Tue, 28 Jun 2022 16:41:44 -0300 Subject: [PATCH 5/5] rename background setting to be disable backgroud; add default value for background setting. --- static/app-strings.json | 1 - ui/component/settingAppearance/index.js | 2 +- ui/component/settingAppearance/view.jsx | 8 ++++---- ui/component/wallpaper/index.js | 2 +- ui/component/wallpaper/view.jsx | 6 +++--- ui/constants/settings.js | 2 +- ui/redux/reducers/settings.js | 1 + 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index 7fa95843d..61bdbd0bd 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -2313,7 +2313,6 @@ "Top content in %language%": "Top content in %language%", "Apply": "Apply", "24-hour clock": "24-hour clock", - "background": "background", "Disable background": "Disable background", "--end--": "--end--" } diff --git a/ui/component/settingAppearance/index.js b/ui/component/settingAppearance/index.js index 40b79f685..7b3f9c2fa 100644 --- a/ui/component/settingAppearance/index.js +++ b/ui/component/settingAppearance/index.js @@ -5,7 +5,7 @@ import { makeSelectClientSetting } from 'redux/selectors/settings'; import SettingAppearance from './view'; const select = (state) => ({ - background: makeSelectClientSetting(SETTINGS.BACKGROUND)(state), + disableBackground: makeSelectClientSetting(SETTINGS.DISABLE_BACKGROUND)(state), clock24h: makeSelectClientSetting(SETTINGS.CLOCK_24H)(state), searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state), hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state), diff --git a/ui/component/settingAppearance/view.jsx b/ui/component/settingAppearance/view.jsx index 634f74a87..2065a5c7e 100644 --- a/ui/component/settingAppearance/view.jsx +++ b/ui/component/settingAppearance/view.jsx @@ -12,7 +12,7 @@ import ThemeSelector from 'component/themeSelector'; import homepages from 'homepages'; type Props = { - background: boolean, + disableBackground: boolean, clock24h: boolean, searchInLanguage: boolean, hideBalance: boolean, @@ -21,7 +21,7 @@ type Props = { }; export default function SettingAppearance(props: Props) { - const { clock24h, background, searchInLanguage, hideBalance, setClientSetting, setSearchInLanguage } = props; + const { clock24h, disableBackground, searchInLanguage, hideBalance, setClientSetting, setSearchInLanguage } = props; return ( <> @@ -68,8 +68,8 @@ export default function SettingAppearance(props: Props) { setClientSetting(SETTINGS.BACKGROUND, !background)} - checked={background} + onChange={() => setClientSetting(SETTINGS.DISABLE_BACKGROUND, !disableBackground)} + checked={disableBackground} /> diff --git a/ui/component/wallpaper/index.js b/ui/component/wallpaper/index.js index 5a13e32f7..2df615c90 100644 --- a/ui/component/wallpaper/index.js +++ b/ui/component/wallpaper/index.js @@ -4,7 +4,7 @@ import * as SETTINGS from 'constants/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings'; const select = (state) => ({ - background: makeSelectClientSetting(SETTINGS.BACKGROUND)(state), + disableBackground: makeSelectClientSetting(SETTINGS.DISABLE_BACKGROUND)(state), }); const perform = {}; diff --git a/ui/component/wallpaper/view.jsx b/ui/component/wallpaper/view.jsx index 11ef316ba..8fd610165 100644 --- a/ui/component/wallpaper/view.jsx +++ b/ui/component/wallpaper/view.jsx @@ -8,11 +8,11 @@ type Props = { // cover: ?string, // avatar: ?string, reset: ?boolean, - background: ?boolean, + disableBackground: ?boolean, }; const Wallpaper = (props: Props) => { - const { background } = props; + const { disableBackground } = props; /* if (avatar) { @@ -234,7 +234,7 @@ const Wallpaper = (props: Props) => {
diff --git a/ui/constants/settings.js b/ui/constants/settings.js index 8b8bfb713..9121f71bc 100644 --- a/ui/constants/settings.js +++ b/ui/constants/settings.js @@ -14,7 +14,7 @@ export const THEME = 'theme'; export const THEMES = 'themes'; export const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled'; export const CLOCK_24H = 'clock_24h'; -export const BACKGROUND = 'background'; +export const DISABLE_BACKGROUND = 'disableBackground'; export const AUTOPLAY_MEDIA = 'autoplay'; export const AUTOPLAY_NEXT = 'autoplay_next'; export const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled'; diff --git a/ui/redux/reducers/settings.js b/ui/redux/reducers/settings.js index 36e6250db..f82faf6f6 100644 --- a/ui/redux/reducers/settings.js +++ b/ui/redux/reducers/settings.js @@ -40,6 +40,7 @@ const defaultState = { [SETTINGS.OS_NOTIFICATIONS_ENABLED]: true, [SETTINGS.AUTOMATIC_DARK_MODE_ENABLED]: false, [SETTINGS.CLOCK_24H]: false, + [SETTINGS.DISABLE_BACKGROUND]: false, [SETTINGS.TILE_LAYOUT]: true, [SETTINGS.VIDEO_THEATER_MODE]: false, [SETTINGS.VIDEO_PLAYBACK_RATE]: 1, -- 2.45.2