From 49d69a293bf431a850b86dd13f7a271e548132e4 Mon Sep 17 00:00:00 2001 From: 0xh3xa <9023404+0xh3xa@users.noreply.github.com> Date: Sat, 29 Mar 2025 01:27:38 +0100 Subject: [PATCH 1/2] Fix selected theme not loading when refreshing --- src/web/waiters/OptionsWaiter.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/web/waiters/OptionsWaiter.mjs b/src/web/waiters/OptionsWaiter.mjs index 4f4eda89..ea4a9c4e 100644 --- a/src/web/waiters/OptionsWaiter.mjs +++ b/src/web/waiters/OptionsWaiter.mjs @@ -167,8 +167,12 @@ class OptionsWaiter { * Applies the user's preferred color scheme using the `prefers-color-scheme` media query. */ applyPreferredColorScheme() { - const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches; - const theme = prefersDarkScheme ? "dark" : "classic"; + const themeFromStorage = this.app?.options?.theme; + let theme = themeFromStorage; + if (!theme) { + const preferredTheme = (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "classic"); + theme = preferredTheme; + } this.changeTheme(theme); } From 0e7b1f7c7810539006f3709ce869d23f29d1dc26 Mon Sep 17 00:00:00 2001 From: heaprc <9023404+0xh3xa@users.noreply.github.com> Date: Thu, 3 Apr 2025 09:31:53 +0200 Subject: [PATCH 2/2] resolve conflict in applyPreferredColorScheme method --- src/web/waiters/OptionsWaiter.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/web/waiters/OptionsWaiter.mjs b/src/web/waiters/OptionsWaiter.mjs index 365bd695..dcb0a5f4 100644 --- a/src/web/waiters/OptionsWaiter.mjs +++ b/src/web/waiters/OptionsWaiter.mjs @@ -178,8 +178,7 @@ class OptionsWaiter { const themeFromStorage = this.app?.options?.theme; let theme = themeFromStorage; if (!theme) { - const preferredTheme = (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "classic"); - theme = preferredTheme; + theme = this.getPreferredColorScheme(); } this.changeTheme(theme); }