From 1a2fefa6ec52b943507848185b73e509985f36f8 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 31 Mar 2022 22:19:19 +0800 Subject: [PATCH] Option to hide notification count in title bar --- static/app-strings.json | 1 + ui/component/router/index.js | 4 +++- ui/component/router/view.jsx | 4 +++- ui/component/settingAppearance/index.js | 1 + ui/component/settingAppearance/view.jsx | 20 +++++++++++++++++++- ui/constants/settings.js | 1 + ui/constants/shared_preferences.js | 1 + ui/redux/reducers/settings.js | 1 + 8 files changed, 30 insertions(+), 3 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index b87647d2f..5f57fc40e 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -423,6 +423,7 @@ "Automatic dark mode": "Automatic dark mode", "24-hour clock": "24-hour clock", "Hide wallet balance in header": "Hide wallet balance in header", + "Hide notification count in title bar": "Hide notification count in title bar", "Show All": "Show All", "names cannot contain spaces or reserved symbols": "names cannot contain spaces or reserved symbols", "Creating channel...": "Creating channel...", diff --git a/ui/component/router/index.js b/ui/component/router/index.js index 6bc96e3a1..13d57e7e1 100644 --- a/ui/component/router/index.js +++ b/ui/component/router/index.js @@ -1,7 +1,8 @@ import { connect } from 'react-redux'; +import * as SETTINGS from 'constants/settings'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectHasNavigated, selectScrollStartingPosition } from 'redux/selectors/app'; -import { selectHomepageData, selectWildWestDisabled } from 'redux/selectors/settings'; +import { selectClientSetting, selectHomepageData, selectWildWestDisabled } from 'redux/selectors/settings'; import Router from './view'; import { normalizeURI } from 'util/lbryURI'; import { selectTitleForUri } from 'redux/selectors/claims'; @@ -37,6 +38,7 @@ const select = (state) => { homepageData: selectHomepageData(state), wildWestDisabled: selectWildWestDisabled(state), unseenCount: selectUnseenNotificationCount(state), + hideTitleNotificationCount: selectClientSetting(state, SETTINGS.HIDE_TITLE_NOTIFICATION_COUNT), }; }; diff --git a/ui/component/router/view.jsx b/ui/component/router/view.jsx index 9271fc9ad..1f4b855ad 100644 --- a/ui/component/router/view.jsx +++ b/ui/component/router/view.jsx @@ -139,6 +139,7 @@ type Props = { homepageData: any, wildWestDisabled: boolean, unseenCount: number, + hideTitleNotificationCount: boolean, }; type PrivateRouteProps = Props & { @@ -179,6 +180,7 @@ function AppRouter(props: Props) { homepageData, wildWestDisabled, unseenCount, + hideTitleNotificationCount, } = props; const { entries, listen, action: historyAction } = history; @@ -247,7 +249,7 @@ function AppRouter(props: Props) { document.title = getDefaultTitle(pathname); } - if (unseenCount > 0) { + if (unseenCount > 0 && !hideTitleNotificationCount) { document.title = `(${buildUnseenCountStr(unseenCount)}) ${document.title}`; } }, [pathname, entries, entryIndex, title, uri, unseenCount]); diff --git a/ui/component/settingAppearance/index.js b/ui/component/settingAppearance/index.js index 0ecbf6950..843a56f56 100644 --- a/ui/component/settingAppearance/index.js +++ b/ui/component/settingAppearance/index.js @@ -10,6 +10,7 @@ const select = (state) => ({ searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE), isAuthenticated: selectUserVerifiedEmail(state), hideBalance: selectClientSetting(state, SETTINGS.HIDE_BALANCE), + hideTitleNotificationCount: selectClientSetting(state, SETTINGS.HIDE_TITLE_NOTIFICATION_COUNT), }); const perform = (dispatch) => ({ diff --git a/ui/component/settingAppearance/view.jsx b/ui/component/settingAppearance/view.jsx index 75ece48ce..6b0a4861c 100644 --- a/ui/component/settingAppearance/view.jsx +++ b/ui/component/settingAppearance/view.jsx @@ -16,12 +16,21 @@ type Props = { searchInLanguage: boolean, isAuthenticated: boolean, hideBalance: boolean, + hideTitleNotificationCount: boolean, setClientSetting: (string, boolean | string | number) => void, setSearchInLanguage: (boolean) => void, }; export default function SettingAppearance(props: Props) { - const { clock24h, searchInLanguage, isAuthenticated, hideBalance, setClientSetting, setSearchInLanguage } = props; + const { + clock24h, + searchInLanguage, + isAuthenticated, + hideBalance, + hideTitleNotificationCount, + setClientSetting, + setSearchInLanguage, + } = props; const { location: { hash }, } = useHistory(); @@ -83,6 +92,15 @@ export default function SettingAppearance(props: Props) { /> )} + + + setClientSetting(SETTINGS.HIDE_TITLE_NOTIFICATION_COUNT, !hideTitleNotificationCount)} + checked={hideTitleNotificationCount} + /> + } /> diff --git a/ui/constants/settings.js b/ui/constants/settings.js index 8bf31365c..361fd0424 100644 --- a/ui/constants/settings.js +++ b/ui/constants/settings.js @@ -21,6 +21,7 @@ export const AUTO_DOWNLOAD = 'auto_download'; export const AUTO_LAUNCH = 'auto_launch'; export const HIDE_BALANCE = 'hide_balance'; export const HIDE_SPLASH_ANIMATION = 'hide_splash_animation'; +export const HIDE_TITLE_NOTIFICATION_COUNT = 'hide_title_notification_count'; export const FLOATING_PLAYER = 'floating_player'; export const DARK_MODE_TIMES = 'dark_mode_times'; export const ENABLE_SYNC = 'enable_sync'; diff --git a/ui/constants/shared_preferences.js b/ui/constants/shared_preferences.js index 95f339694..55e63501e 100644 --- a/ui/constants/shared_preferences.js +++ b/ui/constants/shared_preferences.js @@ -26,6 +26,7 @@ export const CLIENT_SYNC_KEYS = [ SETTINGS.AUTOPLAY_NEXT, SETTINGS.HIDE_BALANCE, SETTINGS.HIDE_SPLASH_ANIMATION, + SETTINGS.HIDE_TITLE_NOTIFICATION_COUNT, SETTINGS.FLOATING_PLAYER, SETTINGS.DARK_MODE_TIMES, SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, diff --git a/ui/redux/reducers/settings.js b/ui/redux/reducers/settings.js index f2d4c4471..6163cbab6 100644 --- a/ui/redux/reducers/settings.js +++ b/ui/redux/reducers/settings.js @@ -47,6 +47,7 @@ const defaultState = { [SETTINGS.HOMEPAGE_ORDER]: { active: null, hidden: null }, [SETTINGS.HIDE_SPLASH_ANIMATION]: false, [SETTINGS.HIDE_BALANCE]: false, + [SETTINGS.HIDE_TITLE_NOTIFICATION_COUNT]: false, [SETTINGS.OS_NOTIFICATIONS_ENABLED]: true, [SETTINGS.AUTOMATIC_DARK_MODE_ENABLED]: false, [SETTINGS.CLOCK_24H]: false,