Fixed confusing theme application until a choice is made.
This commit is contained in:
parent
f554d90199
commit
8848719881
|
@ -75,13 +75,14 @@
|
|||
}
|
||||
|
||||
let refreshVintage = isVintage => {
|
||||
document.documentElement.classList.toggle("vintage", isVintage);
|
||||
document.documentElement.classList.toggle("vintage", isVintage === true);
|
||||
if (browser.browserAction) {
|
||||
browser.browserAction.setIcon({path: {64: `/img${isVintage ? "/vintage/" : "/"}ui-maybe64.png` }});
|
||||
}
|
||||
updateFavIcon(isVintage);
|
||||
}
|
||||
|
||||
const THEMES = ["dark", "light", "auto"];
|
||||
var Themes = {
|
||||
setup(theme = null) {
|
||||
if (theme) {
|
||||
|
@ -94,6 +95,7 @@
|
|||
} else {
|
||||
if (localStorage) {
|
||||
theme = localStorage.getItem("theme");
|
||||
if (!THEMES.includes(theme)) theme = null;
|
||||
}
|
||||
if (!theme && browser && browser.storage) {
|
||||
if (document.readyState === "loading") {
|
||||
|
@ -102,8 +104,8 @@
|
|||
return browser.storage.local.get(["theme"]).then(({theme}) => {
|
||||
update(theme);
|
||||
document.documentElement.style.visibility = "";
|
||||
if (localStorage) localStorage.setItem("theme", theme)
|
||||
return theme;
|
||||
if (localStorage && theme) localStorage.setItem("theme", theme)
|
||||
return theme || "auto";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ document.querySelector("#version").textContent = _("Version",
|
|||
|
||||
UI.wireChoice("theme", o => Themes.setup(o && o.value) );
|
||||
|
||||
opt("vintageTheme", o => o ? Themes.setVintage(o.checked) : Themes.isVintage());
|
||||
opt("vintageTheme", async o => await (o ? Themes.setVintage(o.checked) : Themes.isVintage()));
|
||||
|
||||
// PRESET CUSTOMIZER
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue