diff --git a/ts/components/AboutView.tsx b/ts/components/AboutView.tsx index 11b81beb9..8f7cb71cd 100644 --- a/ts/components/AboutView.tsx +++ b/ts/components/AboutView.tsx @@ -35,12 +35,12 @@ export const AboutView = () => { } useEffect(() => { - if ((window as any).theme) { + if (window.theme) { void switchThemeTo({ - theme: (window as any).theme, + theme: window.theme, }); } - }, []); + }, [window.theme]); return ( diff --git a/ts/components/DebugLogView.tsx b/ts/components/DebugLogView.tsx index 2eeb809cd..80a654f65 100644 --- a/ts/components/DebugLogView.tsx +++ b/ts/components/DebugLogView.tsx @@ -77,9 +77,7 @@ const DebugLogViewAndSave = () => { useEffect(() => { const operatingSystemInfo = `Operating System: ${(window as any).getOSRelease()}`; - const commitHashInfo = (window as any).getCommitHash() - ? `Commit Hash: ${(window as any).getCommitHash()}` - : ''; + const commitHashInfo = window.getCommitHash() ? `Commit Hash: ${window.getCommitHash()}` : ''; // eslint-disable-next-line more/no-then fetch() @@ -100,12 +98,12 @@ const DebugLogViewAndSave = () => { export const DebugLogView = () => { useEffect(() => { - if ((window as any).theme) { + if (window.theme) { void switchThemeTo({ - theme: (window as any).theme, + theme: window.theme, }); } - }, []); + }, [window.theme]); return ( @@ -116,7 +114,7 @@ export const DebugLogView = () => { iconType="exit" iconSize="medium" onClick={() => { - (window as any).closeDebugLog(); + window.closeDebugLog(); }} />

{window.i18n('debugLog')}

diff --git a/ts/components/SessionPasswordPrompt.tsx b/ts/components/SessionPasswordPrompt.tsx index ca9ffd770..fb590f15c 100644 --- a/ts/components/SessionPasswordPrompt.tsx +++ b/ts/components/SessionPasswordPrompt.tsx @@ -195,15 +195,15 @@ class SessionPasswordPromptInner extends React.PureComponent<{}, State> { export const SessionPasswordPrompt = () => { useEffect(() => { - if ((window as any).theme) { + if (window.theme) { void switchThemeTo({ - theme: (window as any).theme, + theme: window.theme, }); } - if ((window as any).primaryColor) { - void switchPrimaryColorTo((window as any).primaryColor); + if (window.primaryColor) { + void switchPrimaryColorTo(window.primaryColor); } - }, []); + }, [window.theme, window.primaryColor]); return ( diff --git a/ts/window.d.ts b/ts/window.d.ts index 70de3a572..20662cb04 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -7,6 +7,7 @@ import { Store } from '@reduxjs/toolkit'; import { ConversationCollection, ConversationModel } from './models/conversation'; import { ConversationType } from './state/ducks/conversations'; import { StateType } from './state/reducer'; +import { PrimaryColorStateType, ThemeStateType } from './themes/constants/colors'; export interface LibTextsecure { messaging: boolean; @@ -54,6 +55,8 @@ declare global { getCallMediaPermissions: () => boolean; toggleMenuBar: () => void; toggleSpellCheck: any; + primaryColor: PrimaryColorStateType; + theme: ThemeStateType; setTheme: (newTheme: string) => Promise; isDev?: () => boolean; userConfig: any; @@ -96,6 +99,7 @@ declare global { getOpengroupPruning: () => Promise; setOpengroupPruning: (val: boolean) => Promise; closeAbout: () => void; + closeDebugLog: () => void; getAutoUpdateEnabled: () => boolean; setAutoUpdateEnabled: (enabled: boolean) => void; setZoomFactor: (newZoom: number) => void;