mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
only single selected theme or custom background at once
This commit is contained in:
+10
-4
@@ -84,9 +84,14 @@ const applyTheme = async (themeName) => {
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const listThemes = async () => {
|
||||
const themes = await localforage.keys();
|
||||
return themes.filter((key) => key.startsWith("css_")).map((key) => key.replace("css_", ""));
|
||||
console.log("Themes in IndexedDB:", themes);
|
||||
return {
|
||||
themes: themes.filter((key) => key.startsWith("css_")).map((key) => key.replace("css_", "")),
|
||||
selectedTheme: await localforage.getItem("selectedTheme")
|
||||
};
|
||||
};
|
||||
|
||||
export const downloadTheme = async (themeName, themeUrl) => {
|
||||
@@ -101,14 +106,15 @@ export const setTheme = async (themeName, themeUrl) => {
|
||||
await downloadTheme(themeName, themeUrl);
|
||||
}
|
||||
|
||||
localforage.setItem("selectedTheme", themeName);
|
||||
await localforage.setItem("selectedTheme", themeName);
|
||||
await applyTheme(themeName).catch((error) => {
|
||||
console.error(`Failed to apply theme: ${error}`);
|
||||
});
|
||||
};
|
||||
|
||||
export const enableCurrentTheme = async () => {
|
||||
const currentTheme = localforage.getItem("selectedTheme");
|
||||
console.log("Enabling current theme...");
|
||||
const currentTheme = await localforage.getItem("selectedTheme");
|
||||
|
||||
if (currentTheme) {
|
||||
console.log(`Enabling current theme: ${currentTheme}`);
|
||||
@@ -136,7 +142,7 @@ export const disableTheme = async () => {
|
||||
}
|
||||
|
||||
// Remove any applied image URLs from the root element
|
||||
const currentTheme = localforage.getItem("selectedTheme");
|
||||
const currentTheme = await localforage.getItem("selectedTheme");
|
||||
if (currentTheme) {
|
||||
const themeData = await localforage.getItem(`css_${currentTheme}`);
|
||||
if (themeData && themeData.images) {
|
||||
|
||||
@@ -14,6 +14,8 @@ export class MessageHandler {
|
||||
case "EditSidebar":
|
||||
this.editSidebar();
|
||||
break;
|
||||
|
||||
/* Theme related */
|
||||
case "SetTheme":
|
||||
console.log(request);
|
||||
setTheme(request.body.themeName, request.body.themeURL).then(() => {
|
||||
@@ -26,8 +28,8 @@ export class MessageHandler {
|
||||
});
|
||||
return true;
|
||||
case "ListThemes":
|
||||
listThemes().then((themes) => {
|
||||
sendResponse({ themes });
|
||||
listThemes().then((response) => {
|
||||
sendResponse(response);
|
||||
});
|
||||
return true;
|
||||
case "DisableTheme":
|
||||
|
||||
Reference in New Issue
Block a user