Fix dark mode when in light mode os theme

This commit is contained in:
Jamie Kyle 2024-11-06 11:24:16 -08:00 committed by GitHub
parent dc4896c9cb
commit 17a4bfd8d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,20 +2,27 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { SystemThemeType, ThemeType } from '../types/Util';
import { missingCaseError } from './missingCaseError';
export async function getThemeType(): Promise<ThemeType> {
const themeSetting = await window.Events.getThemeSetting();
if (
themeSetting === 'light' ||
window.systemTheme === SystemThemeType.light
) {
if (themeSetting === 'light') {
return ThemeType.light;
}
if (themeSetting === 'dark' || window.systemTheme === SystemThemeType.dark) {
if (themeSetting === '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);
}