Skip to content

Commit 20d978e

Browse files
committed
Fix broken color scheme detection
1 parent 56d347b commit 20d978e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

www/index.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,24 @@ function historyPopStateHandler(e) {
529529
}
530530
}
531531

532+
function setTheme(theme) {
533+
document.body.dataset.theme = theme
534+
}
535+
536+
function toggleTheme() {
537+
setTheme(document.body.dataset.theme === 'dark' ? 'light' : 'dark')
538+
// Only save to local storage if manually toggled by the user
539+
localStorage.setItem('theme', theme)
540+
}
541+
532542
function restoreSettings() {
533543
let theme = localStorage.getItem('theme')
534-
document.body.dataset.theme = theme
535544
compactSignature = localStorage.getItem('compactSignature') === 'true'
536545

537546
if (!theme)
538547
theme = window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light';
539-
}
540548

541-
function toggleTheme() {
542-
const theme = document.body.dataset.theme === 'dark' ? 'light' : 'dark'
543-
document.body.dataset.theme = theme
544-
localStorage.setItem('theme', theme)
549+
setTheme(theme)
545550
}
546551

547552
async function setup() {

0 commit comments

Comments
 (0)