fix(theme): fix persistence of dark mode

This commit is contained in:
Damillora 2021-04-14 22:26:55 +07:00
parent c7187ebcc4
commit fa3ce87d57
1 changed files with 2 additions and 1 deletions

View File

@ -1,5 +1,5 @@
function setDarkMode() {
if (!window.localStorage.getItem('theme') && window.document.body.getAttribute("data-theme")){
if (window.document.body.getAttribute("data-theme")){
window.localStorage.setItem('theme', window.document.body.getAttribute("data-theme"));
}
if (window.document.body.getAttribute("data-theme") == "dark") {
@ -10,6 +10,7 @@ function setDarkMode() {
$("#darkMode p").text("Dark Mode");
}
}
if (window.localStorage.getItem('theme')) {
window.document.body.setAttribute("data-theme", window.localStorage.getItem("theme"));
}