From fa3ce87d57042b42998119342f53815e69e5021e Mon Sep 17 00:00:00 2001 From: Damillora Date: Wed, 14 Apr 2021 22:26:55 +0700 Subject: [PATCH] fix(theme): fix persistence of dark mode --- assets/js/dark-mode.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/js/dark-mode.js b/assets/js/dark-mode.js index 66eeb85..8920152 100644 --- a/assets/js/dark-mode.js +++ b/assets/js/dark-mode.js @@ -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")); }