fix(theme): persist one canonical preference
CI and Deploy / test (pull_request) Failing after 4m32s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-15 13:11:44 +02:00
parent bd5362c8c2
commit 896746319b
5 changed files with 64 additions and 31 deletions
+3 -1
View File
@@ -5,7 +5,9 @@ export const THEME_BOOTSTRAP_SCRIPT = `(() => {
return value === "light" || value === "dark" || value === "system" ? value : null;
};
const userKey = window.localStorage.getItem("authUserKey") || "anon";
const preference = read("themeMode:" + userKey) || (userKey !== "anon" ? read("themeMode:anon") : null) || "system";
const legacyPreference = read("themeMode:" + userKey) || (userKey !== "anon" ? read("themeMode:anon") : null);
const preference = read("jobtracker.themeMode") || legacyPreference || "system";
if (!read("jobtracker.themeMode") && legacyPreference) window.localStorage.setItem("jobtracker.themeMode", legacyPreference);
const mode = preference === "dark" || (preference === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches) ? "dark" : "light";
document.documentElement.setAttribute("data-color-scheme", mode);
document.documentElement.style.colorScheme = mode;