Fix theme change error on init (#4861)
This commit is contained in:
parent
967852580a
commit
547db95ee4
@ -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);
|
||||
|
||||
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@ -66,6 +66,7 @@ export const INITIAL_PERFORMANCE_STATE_MIN: PerformanceType = {
|
||||
};
|
||||
|
||||
export const INITIAL_GLOBAL_STATE: GlobalState = {
|
||||
isInited: true,
|
||||
attachMenu: { bots: {} },
|
||||
passcode: {},
|
||||
twoFaSettings: {},
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -805,6 +805,7 @@ export type TabState = {
|
||||
};
|
||||
|
||||
export type GlobalState = {
|
||||
isInited: boolean;
|
||||
config?: ApiConfig;
|
||||
appConfig?: ApiAppConfig;
|
||||
peerColors?: ApiPeerColors;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user