From 90bda2e3098d8cdc473ad0310ebac5f147c634da Mon Sep 17 00:00:00 2001 From: Ludvig Lundgren Date: Sat, 5 Feb 2022 13:43:49 +0100 Subject: [PATCH] fix: set theme (#111) --- web/src/utils/Context.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/src/utils/Context.ts b/web/src/utils/Context.ts index 4682ad6..a1967cf 100644 --- a/web/src/utils/Context.ts +++ b/web/src/utils/Context.ts @@ -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 + ) + })); } }