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": {
"name": "eslint-plugin-eslint-multitab-tt",
"version": "0.0.0",
"dev": true,
"license": "ISC",

View File

@ -74,7 +74,6 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
loadWebAuthorizations,
showNotification,
setSettingOption,
updatePageTitle,
} = getActions();
useEffect(() => {
@ -118,7 +117,6 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
setSettingOption({
canDisplayChatInTitle: isChecked,
});
updatePageTitle();
}, []);
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 switchTheme from '../../../util/switchTheme';
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;
addCallback((global: GlobalState) => {
const { updatePageTitle } = getActions();
const settings = global.settings.byKey;
const prevSettings = prevGlobal?.settings.byKey;
prevGlobal = global;
@ -48,6 +50,10 @@ addCallback((global: GlobalState) => {
document.documentElement.style.setProperty('--message-text-size', `${settings.messageTextSize}px`);
document.documentElement.setAttribute('data-message-text-size', settings.messageTextSize.toString());
}
if (settings.canDisplayChatInTitle !== prevSettings.canDisplayChatInTitle) {
updatePageTitle();
}
});
addActionHandler('setSettingOption', (global, actions, payload): ActionReturnType => {