Skip to content

Commit

Permalink
only reset the theme if we're resetting from one we own
Browse files Browse the repository at this point in the history
  • Loading branch information
idk committed Jun 11, 2023
1 parent c2de99d commit 5522902
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function themeWindow(window) {
let ctheme = browser.theme.getCurrent();
ctheme.then(setDynamicTheme);
function setDynamicTheme(oldtheme) {
dtheme.images = oldtheme.images;
if (window.incognito) {
browser.theme.update(window.id, dtheme);
} else {
Expand Down Expand Up @@ -407,19 +406,24 @@ browser.tabs.onCreated.addListener(putCurrentThemeInLocalStorage);
function unsetTheme() {
const storedTheme = browser.storage.local.get("theme");
storedTheme.then(restoreTheme, restoreThemeError);
function restoreTheme(theme) {
if (theme.theme) {
console.debug("(theme) analyzing theme", theme.theme);
if (theme.theme.colors) {
theme.theme.images = {};
console.warn("(theme) There's not a way to restore theme images yet.");
browser.theme.update(theme.theme);
console.log("(theme) restored the stored theme", theme);
} else {
browser.theme.reset();
async function restoreTheme(theme) {
let mt = await isMyTheme();
if (mt) {
if (theme.theme) {
console.debug("(theme) analyzing theme", theme.theme);
if (theme.theme.colors) {
theme.theme.images = {};
console.warn(
"(theme) There's not a way to restore theme images yet."
);
browser.theme.update(theme.theme);
console.log("(theme) restored the stored theme", theme);
} else {
browser.theme.reset();
}
}
restoreLatestThemeIDInLocalStorage();
}
restoreLatestThemeIDInLocalStorage();
}
function restoreThemeError(err) {
console.debug("(theme) theme restore error", err);
Expand Down

0 comments on commit 5522902

Please sign in to comment.