Properly lock theme into themes dark or light mode

This commit is contained in:
schroda
2024-09-06 23:29:16 +02:00
parent 290f031479
commit 81fe710531
2 changed files with 4 additions and 3 deletions

View File

@@ -29,8 +29,9 @@ export const createTheme = (
) => {
const systemMode = MediaQuery.getSystemThemeMode();
const isStaticThemeMode = !!appTheme.muiTheme.palette?.mode;
const appThemeMode = appTheme.muiTheme.palette?.mode === 'dark' ? ThemeMode.DARK : ThemeMode.LIGHT;
const appThemeType = (appTheme.muiTheme.palette as any)?.type ?? appTheme.muiTheme.palette?.mode;
const isStaticThemeMode = !!appThemeType;
const appThemeMode = appThemeType === 'dark' ? ThemeMode.DARK : ThemeMode.LIGHT;
const staticThemeMode = isStaticThemeMode ? appThemeMode : undefined;
const mode = staticThemeMode ?? (themeMode === ThemeMode.SYSTEM ? systemMode : themeMode);