fix: pr review - added theme and primaryColor to window type

pull/2522/head
William Grant 3 years ago
parent 8edd2652b2
commit 03d8f39677

@ -35,12 +35,12 @@ export const AboutView = () => {
} }
useEffect(() => { useEffect(() => {
if ((window as any).theme) { if (window.theme) {
void switchThemeTo({ void switchThemeTo({
theme: (window as any).theme, theme: window.theme,
}); });
} }
}, []); }, [window.theme]);
return ( return (
<SessionTheme> <SessionTheme>

@ -77,9 +77,7 @@ const DebugLogViewAndSave = () => {
useEffect(() => { useEffect(() => {
const operatingSystemInfo = `Operating System: ${(window as any).getOSRelease()}`; const operatingSystemInfo = `Operating System: ${(window as any).getOSRelease()}`;
const commitHashInfo = (window as any).getCommitHash() const commitHashInfo = window.getCommitHash() ? `Commit Hash: ${window.getCommitHash()}` : '';
? `Commit Hash: ${(window as any).getCommitHash()}`
: '';
// eslint-disable-next-line more/no-then // eslint-disable-next-line more/no-then
fetch() fetch()
@ -100,12 +98,12 @@ const DebugLogViewAndSave = () => {
export const DebugLogView = () => { export const DebugLogView = () => {
useEffect(() => { useEffect(() => {
if ((window as any).theme) { if (window.theme) {
void switchThemeTo({ void switchThemeTo({
theme: (window as any).theme, theme: window.theme,
}); });
} }
}, []); }, [window.theme]);
return ( return (
<SessionTheme> <SessionTheme>
@ -116,7 +114,7 @@ export const DebugLogView = () => {
iconType="exit" iconType="exit"
iconSize="medium" iconSize="medium"
onClick={() => { onClick={() => {
(window as any).closeDebugLog(); window.closeDebugLog();
}} }}
/> />
<h1> {window.i18n('debugLog')} </h1> <h1> {window.i18n('debugLog')} </h1>

@ -195,15 +195,15 @@ class SessionPasswordPromptInner extends React.PureComponent<{}, State> {
export const SessionPasswordPrompt = () => { export const SessionPasswordPrompt = () => {
useEffect(() => { useEffect(() => {
if ((window as any).theme) { if (window.theme) {
void switchThemeTo({ void switchThemeTo({
theme: (window as any).theme, theme: window.theme,
}); });
} }
if ((window as any).primaryColor) { if (window.primaryColor) {
void switchPrimaryColorTo((window as any).primaryColor); void switchPrimaryColorTo(window.primaryColor);
} }
}, []); }, [window.theme, window.primaryColor]);
return ( return (
<SessionTheme> <SessionTheme>

4
ts/window.d.ts vendored

@ -7,6 +7,7 @@ import { Store } from '@reduxjs/toolkit';
import { ConversationCollection, ConversationModel } from './models/conversation'; import { ConversationCollection, ConversationModel } from './models/conversation';
import { ConversationType } from './state/ducks/conversations'; import { ConversationType } from './state/ducks/conversations';
import { StateType } from './state/reducer'; import { StateType } from './state/reducer';
import { PrimaryColorStateType, ThemeStateType } from './themes/constants/colors';
export interface LibTextsecure { export interface LibTextsecure {
messaging: boolean; messaging: boolean;
@ -54,6 +55,8 @@ declare global {
getCallMediaPermissions: () => boolean; getCallMediaPermissions: () => boolean;
toggleMenuBar: () => void; toggleMenuBar: () => void;
toggleSpellCheck: any; toggleSpellCheck: any;
primaryColor: PrimaryColorStateType;
theme: ThemeStateType;
setTheme: (newTheme: string) => Promise<void>; setTheme: (newTheme: string) => Promise<void>;
isDev?: () => boolean; isDev?: () => boolean;
userConfig: any; userConfig: any;
@ -96,6 +99,7 @@ declare global {
getOpengroupPruning: () => Promise<boolean>; getOpengroupPruning: () => Promise<boolean>;
setOpengroupPruning: (val: boolean) => Promise<void>; setOpengroupPruning: (val: boolean) => Promise<void>;
closeAbout: () => void; closeAbout: () => void;
closeDebugLog: () => void;
getAutoUpdateEnabled: () => boolean; getAutoUpdateEnabled: () => boolean;
setAutoUpdateEnabled: (enabled: boolean) => void; setAutoUpdateEnabled: (enabled: boolean) => void;
setZoomFactor: (newZoom: number) => void; setZoomFactor: (newZoom: number) => void;

Loading…
Cancel
Save