Fix dark mode when in light mode os theme
This commit is contained in:
parent
dc4896c9cb
commit
17a4bfd8d6
1 changed files with 13 additions and 6 deletions
|
@ -2,20 +2,27 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import { SystemThemeType, ThemeType } from '../types/Util';
|
import { SystemThemeType, ThemeType } from '../types/Util';
|
||||||
|
import { missingCaseError } from './missingCaseError';
|
||||||
|
|
||||||
export async function getThemeType(): Promise<ThemeType> {
|
export async function getThemeType(): Promise<ThemeType> {
|
||||||
const themeSetting = await window.Events.getThemeSetting();
|
const themeSetting = await window.Events.getThemeSetting();
|
||||||
|
|
||||||
if (
|
if (themeSetting === 'light') {
|
||||||
themeSetting === 'light' ||
|
|
||||||
window.systemTheme === SystemThemeType.light
|
|
||||||
) {
|
|
||||||
return ThemeType.light;
|
return ThemeType.light;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (themeSetting === 'dark' || window.systemTheme === SystemThemeType.dark) {
|
if (themeSetting === 'dark') {
|
||||||
return ThemeType.dark;
|
return ThemeType.dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
return window.systemTheme;
|
if (themeSetting === 'system') {
|
||||||
|
if (window.systemTheme === SystemThemeType.light) {
|
||||||
|
return ThemeType.light;
|
||||||
|
}
|
||||||
|
if (window.systemTheme === SystemThemeType.dark) {
|
||||||
|
return ThemeType.dark;
|
||||||
|
}
|
||||||
|
throw missingCaseError(window.systemTheme);
|
||||||
|
}
|
||||||
|
throw missingCaseError(themeSetting);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue