Skip to content

Commit 8848719

Browse files
committed
Fixed confusing theme application until a choice is made.
1 parent f554d90 commit 8848719

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/common/themes.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@
7575
}
7676

7777
let refreshVintage = isVintage => {
78-
document.documentElement.classList.toggle("vintage", isVintage);
78+
document.documentElement.classList.toggle("vintage", isVintage === true);
7979
if (browser.browserAction) {
8080
browser.browserAction.setIcon({path: {64: `/img${isVintage ? "/vintage/" : "/"}ui-maybe64.png` }});
8181
}
8282
updateFavIcon(isVintage);
8383
}
8484

85+
const THEMES = ["dark", "light", "auto"];
8586
var Themes = {
8687
setup(theme = null) {
8788
if (theme) {
@@ -94,6 +95,7 @@
9495
} else {
9596
if (localStorage) {
9697
theme = localStorage.getItem("theme");
98+
if (!THEMES.includes(theme)) theme = null;
9799
}
98100
if (!theme && browser && browser.storage) {
99101
if (document.readyState === "loading") {
@@ -102,8 +104,8 @@
102104
return browser.storage.local.get(["theme"]).then(({theme}) => {
103105
update(theme);
104106
document.documentElement.style.visibility = "";
105-
if (localStorage) localStorage.setItem("theme", theme)
106-
return theme;
107+
if (localStorage && theme) localStorage.setItem("theme", theme)
108+
return theme || "auto";
107109
});
108110
}
109111
}

src/ui/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ document.querySelector("#version").textContent = _("Version",
147147

148148
UI.wireChoice("theme", o => Themes.setup(o && o.value) );
149149

150-
opt("vintageTheme", o => o ? Themes.setVintage(o.checked) : Themes.isVintage());
150+
opt("vintageTheme", async o => await (o ? Themes.setVintage(o.checked) : Themes.isVintage()));
151151

152152
// PRESET CUSTOMIZER
153153
{

0 commit comments

Comments
 (0)