fix: set theme (#111)

This commit is contained in:
Ludvig Lundgren 2022-02-05 13:43:49 +01:00 committed by GitHub
parent 0076ea9129
commit 90bda2e309
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,13 +11,13 @@ export const InitializeGlobalContext = () => {
SettingsContext.set(JSON.parse(settings_ctx)); SettingsContext.set(JSON.parse(settings_ctx));
} else { } else {
// Only check for light theme, otherwise dark theme is the default // Only check for light theme, otherwise dark theme is the default
const userMedia = window.matchMedia("(prefers-color-scheme: light)"); SettingsContext.set((state) => ({
if (userMedia.matches) { ...state,
SettingsContext.set((state) => ({ darkTheme: !(
...state, window.matchMedia !== undefined &&
darkTheme: false window.matchMedia("(prefers-color-scheme: light)").matches
})); )
} }));
} }
} }