Page Title: Sync setting between tabs (#2751)

This commit is contained in:
Alexander Zinchuk 2023-03-10 02:33:58 +01:00
parent 27842a1cf3
commit 4090cf093d
3 changed files with 7 additions and 4 deletions

1
package-lock.json generated
View File

@ -105,7 +105,6 @@
} }
}, },
"dev/eslint-multitab": { "dev/eslint-multitab": {
"name": "eslint-plugin-eslint-multitab-tt",
"version": "0.0.0", "version": "0.0.0",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",

View File

@ -74,7 +74,6 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
loadWebAuthorizations, loadWebAuthorizations,
showNotification, showNotification,
setSettingOption, setSettingOption,
updatePageTitle,
} = getActions(); } = getActions();
useEffect(() => { useEffect(() => {
@ -118,7 +117,6 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
setSettingOption({ setSettingOption({
canDisplayChatInTitle: isChecked, canDisplayChatInTitle: isChecked,
}); });
updatePageTitle();
}, []); }, []);
const handleUpdateContentSettings = useCallback((isChecked: boolean) => { const handleUpdateContentSettings = useCallback((isChecked: boolean) => {

View File

@ -1,4 +1,4 @@
import { addActionHandler } from '../../index'; import { addActionHandler, getActions } from '../../index';
import { replaceSettings, replaceThemeSettings } from '../../reducers'; import { replaceSettings, replaceThemeSettings } from '../../reducers';
import switchTheme from '../../../util/switchTheme'; import switchTheme from '../../../util/switchTheme';
import { ANIMATION_LEVEL_MAX, ANIMATION_LEVEL_MED, ANIMATION_LEVEL_MIN } from '../../../config'; import { ANIMATION_LEVEL_MAX, ANIMATION_LEVEL_MED, ANIMATION_LEVEL_MIN } from '../../../config';
@ -12,6 +12,8 @@ import { getCurrentTabId } from '../../../util/establishMultitabRole';
let prevGlobal: GlobalState | undefined; let prevGlobal: GlobalState | undefined;
addCallback((global: GlobalState) => { addCallback((global: GlobalState) => {
const { updatePageTitle } = getActions();
const settings = global.settings.byKey; const settings = global.settings.byKey;
const prevSettings = prevGlobal?.settings.byKey; const prevSettings = prevGlobal?.settings.byKey;
prevGlobal = global; prevGlobal = global;
@ -48,6 +50,10 @@ addCallback((global: GlobalState) => {
document.documentElement.style.setProperty('--message-text-size', `${settings.messageTextSize}px`); document.documentElement.style.setProperty('--message-text-size', `${settings.messageTextSize}px`);
document.documentElement.setAttribute('data-message-text-size', settings.messageTextSize.toString()); document.documentElement.setAttribute('data-message-text-size', settings.messageTextSize.toString());
} }
if (settings.canDisplayChatInTitle !== prevSettings.canDisplayChatInTitle) {
updatePageTitle();
}
}); });
addActionHandler('setSettingOption', (global, actions, payload): ActionReturnType => { addActionHandler('setSettingOption', (global, actions, payload): ActionReturnType => {