Fix theme change error on init (#4861)

This commit is contained in:
zubiden 2024-08-06 20:06:54 +02:00 committed by Alexander Zinchuk
parent 967852580a
commit 547db95ee4
6 changed files with 11 additions and 3 deletions

View File

@ -32,7 +32,7 @@ setSystemThemeChangeCallback((theme) => {
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
let global = getGlobal();
if (!global.settings.byKey.shouldUseSystemTheme) return;
if (!global.isInited || !global.settings.byKey.shouldUseSystemTheme) return;
global = replaceSettings(global, { theme });
setGlobal(global);

View File

@ -16,7 +16,9 @@ import { clearPasscodeSettings, updatePasscodeSettings } from '../../reducers';
let noLockOnUnload = false;
onBeforeUnload(() => {
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
if (getGlobal().passcode.hasPasscode && !noLockOnUnload && Object.keys(getGlobal().byTabId).length === 1) {
const global = getGlobal();
if (!global.isInited) return;
if (global.passcode.hasPasscode && !noLockOnUnload && Object.keys(global.byTabId).length === 1) {
clearStoredSession();
}
});

View File

@ -66,6 +66,7 @@ export const INITIAL_PERFORMANCE_STATE_MIN: PerformanceType = {
};
export const INITIAL_GLOBAL_STATE: GlobalState = {
isInited: true,
attachMenu: { bots: {} },
passcode: {},
twoFaSettings: {},

View File

@ -41,6 +41,8 @@ function stopIntervals() {
function checkStoryExpiration() {
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
let global = getGlobal();
if (!global.isInited) return;
const serverTime = getServerTime();
Object.values(global.stories.byPeerId).forEach((peerStories) => {

View File

@ -805,6 +805,7 @@ export type TabState = {
};
export type GlobalState = {
isInited: boolean;
config?: ApiConfig;
appConfig?: ApiAppConfig;
peerColors?: ApiPeerColors;

View File

@ -52,7 +52,9 @@ type ActivationFn<OwnProps = undefined> = (
global: GlobalState, ownProps: OwnProps, stickToFirst: StickToFirstFn,
) => boolean;
let currentGlobal = {} as GlobalState;
let currentGlobal = {
isInited: false,
} as GlobalState;
// eslint-disable-next-line @typescript-eslint/naming-convention
let DEBUG_currentCapturedId: number | undefined;