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
|
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
|
||||||
let global = getGlobal();
|
let global = getGlobal();
|
||||||
|
|
||||||
if (!global.settings.byKey.shouldUseSystemTheme) return;
|
if (!global.isInited || !global.settings.byKey.shouldUseSystemTheme) return;
|
||||||
|
|
||||||
global = replaceSettings(global, { theme });
|
global = replaceSettings(global, { theme });
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|||||||
@ -16,7 +16,9 @@ import { clearPasscodeSettings, updatePasscodeSettings } from '../../reducers';
|
|||||||
let noLockOnUnload = false;
|
let noLockOnUnload = false;
|
||||||
onBeforeUnload(() => {
|
onBeforeUnload(() => {
|
||||||
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
|
// 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();
|
clearStoredSession();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -66,6 +66,7 @@ export const INITIAL_PERFORMANCE_STATE_MIN: PerformanceType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const INITIAL_GLOBAL_STATE: GlobalState = {
|
export const INITIAL_GLOBAL_STATE: GlobalState = {
|
||||||
|
isInited: true,
|
||||||
attachMenu: { bots: {} },
|
attachMenu: { bots: {} },
|
||||||
passcode: {},
|
passcode: {},
|
||||||
twoFaSettings: {},
|
twoFaSettings: {},
|
||||||
|
|||||||
@ -41,6 +41,8 @@ function stopIntervals() {
|
|||||||
function checkStoryExpiration() {
|
function checkStoryExpiration() {
|
||||||
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
|
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
|
||||||
let global = getGlobal();
|
let global = getGlobal();
|
||||||
|
if (!global.isInited) return;
|
||||||
|
|
||||||
const serverTime = getServerTime();
|
const serverTime = getServerTime();
|
||||||
|
|
||||||
Object.values(global.stories.byPeerId).forEach((peerStories) => {
|
Object.values(global.stories.byPeerId).forEach((peerStories) => {
|
||||||
|
|||||||
@ -805,6 +805,7 @@ export type TabState = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type GlobalState = {
|
export type GlobalState = {
|
||||||
|
isInited: boolean;
|
||||||
config?: ApiConfig;
|
config?: ApiConfig;
|
||||||
appConfig?: ApiAppConfig;
|
appConfig?: ApiAppConfig;
|
||||||
peerColors?: ApiPeerColors;
|
peerColors?: ApiPeerColors;
|
||||||
|
|||||||
@ -52,7 +52,9 @@ type ActivationFn<OwnProps = undefined> = (
|
|||||||
global: GlobalState, ownProps: OwnProps, stickToFirst: StickToFirstFn,
|
global: GlobalState, ownProps: OwnProps, stickToFirst: StickToFirstFn,
|
||||||
) => boolean;
|
) => boolean;
|
||||||
|
|
||||||
let currentGlobal = {} as GlobalState;
|
let currentGlobal = {
|
||||||
|
isInited: false,
|
||||||
|
} as GlobalState;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
let DEBUG_currentCapturedId: number | undefined;
|
let DEBUG_currentCapturedId: number | undefined;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user