Option to hide notification count in title bar

This commit is contained in:
infinite-persistence 2022-03-31 22:19:19 +08:00 committed by Thomas Zarebczan
parent 3b98f73a0f
commit 1a2fefa6ec
8 changed files with 30 additions and 3 deletions

View file

@ -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...",

View file

@ -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),
};
};

View file

@ -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]);

View file

@ -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) => ({

View file

@ -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) {
/>
</SettingsRow>
)}
<SettingsRow title={__('Hide notification count in title bar')}>
<FormField
type="checkbox"
name="hide_title_notification_count"
onChange={() => setClientSetting(SETTINGS.HIDE_TITLE_NOTIFICATION_COUNT, !hideTitleNotificationCount)}
checked={hideTitleNotificationCount}
/>
</SettingsRow>
</>
}
/>

View file

@ -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';

View file

@ -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,

View file

@ -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,