Fixed first time theme change from dark mode

If the theme is detected as dark, the first click on the toggle theme button will now change to light mode.
Preveously no change would occur, since it would switch from default dark to force dark mode.
This commit is contained in:
Morpheus0x 2022-08-26 14:58:00 +02:00
parent 345c1cb020
commit de360c4ca4

View file

@ -27,8 +27,14 @@ function detectOSColorTheme() {
function switchTheme(e) {
if (chosenThemeIsDark) {
localStorage.setItem("theme", "light");
} else {
} else if (chosenThemeIsLight) {
localStorage.setItem("theme", "dark");
} else {
if (document.documentElement.getAttribute("data-theme") == "dark") {
localStorage.setItem("theme", "light");
} else {
localStorage.setItem("theme", "dark");
}
}
detectOSColorTheme();