From b67e883effa7bdfb99e19599f5c71682d8c15c77 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 21 Dec 2022 11:29:15 +0100 Subject: [PATCH] fix: dont write color mode defaults to local storage (#345) --- src/js/colorTheme.js | 3 +-- src/js/mermaid.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/js/colorTheme.js b/src/js/colorTheme.js index e069e25..5460b07 100644 --- a/src/js/colorTheme.js +++ b/src/js/colorTheme.js @@ -7,7 +7,7 @@ document.addEventListener("DOMContentLoaded", (event) => { colorThemeToggle.onclick = function () { let lstore = Storage.namespace(THEME) - let currentColorTheme = lstore.get("color-theme") + let currentColorTheme = lstore.get("color-theme") || COLOR_THEME_AUTO let nextColorTheme = toggle(TOGGLE_COLOR_THEMES, currentColorTheme) lstore.set("color-theme", TOGGLE_COLOR_THEMES[nextColorTheme]) @@ -25,7 +25,6 @@ export function applyTheme(init = true) { : COLOR_THEME_AUTO html.setAttribute("class", "color-toggle-" + currentColorTheme) - lstore.set("color-theme", currentColorTheme) if (currentColorTheme === COLOR_THEME_AUTO) { html.removeAttribute("color-theme") diff --git a/src/js/mermaid.js b/src/js/mermaid.js index 65ca8f8..af64ad7 100644 --- a/src/js/mermaid.js +++ b/src/js/mermaid.js @@ -3,7 +3,7 @@ const { COLOR_THEME_DARK, THEME, COLOR_THEME_AUTO } = require("./config.js") document.addEventListener("DOMContentLoaded", function (event) { let lstore = Storage.namespace(THEME) - let currentColorTheme = lstore.get("color-theme") + let currentColorTheme = lstore.get("color-theme") || COLOR_THEME_AUTO let darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)") let darkMode = false let theme = "default"