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));
} else {
// Only check for light theme, otherwise dark theme is the default
const userMedia = window.matchMedia("(prefers-color-scheme: light)");
if (userMedia.matches) {
SettingsContext.set((state) => ({
...state,
darkTheme: false
}));
}
SettingsContext.set((state) => ({
...state,
darkTheme: !(
window.matchMedia !== undefined &&
window.matchMedia("(prefers-color-scheme: light)").matches
)
}));
}
}