fix: dont write color mode defaults to local storage (#528)

This commit is contained in:
Robert Kaussow 2022-11-02 15:09:14 +01:00 committed by GitHub
parent 128a55e974
commit d0a7f2bb60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View file

@ -7,7 +7,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
colorThemeToggle.onclick = function () { colorThemeToggle.onclick = function () {
let lstore = Storage.namespace(THEME) 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) let nextColorTheme = toggle(TOGGLE_COLOR_THEMES, currentColorTheme)
lstore.set("color-theme", TOGGLE_COLOR_THEMES[nextColorTheme]) lstore.set("color-theme", TOGGLE_COLOR_THEMES[nextColorTheme])
@ -25,7 +25,6 @@ export function applyTheme(init = true) {
: COLOR_THEME_AUTO : COLOR_THEME_AUTO
html.setAttribute("class", "color-toggle-" + currentColorTheme) html.setAttribute("class", "color-toggle-" + currentColorTheme)
lstore.set("color-theme", currentColorTheme)
if (currentColorTheme === COLOR_THEME_AUTO) { if (currentColorTheme === COLOR_THEME_AUTO) {
html.removeAttribute("color-theme") html.removeAttribute("color-theme")

View file

@ -3,7 +3,7 @@ const { COLOR_THEME_DARK, THEME, COLOR_THEME_AUTO } = require("./config.js")
document.addEventListener("DOMContentLoaded", function (event) { document.addEventListener("DOMContentLoaded", function (event) {
let lstore = Storage.namespace(THEME) let lstore = Storage.namespace(THEME)
let currentMode = lstore.get("color-theme") let currentMode = lstore.get("color-theme") || COLOR_THEME_AUTO
let darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)") let darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)")
let darkMode = false let darkMode = false
let theme = "default" let theme = "default"