fix theme removal setting theme

This commit is contained in:
SethBurkart123
2023-11-03 11:08:51 +11:00
parent 2185b5d0b3
commit 95b8dd6cae
+5
View File
@@ -92,10 +92,15 @@ export const downloadTheme = async (themeName, themeUrl) => {
const themeData = await fetchThemeJSON(themeUrl); const themeData = await fetchThemeJSON(themeUrl);
await saveToIndexedDB(themeData, themeName); await saveToIndexedDB(themeData, themeName);
console.log(`Theme ${themeName} saved to IndexedDB`); console.log(`Theme ${themeName} saved to IndexedDB`);
await setTheme(themeName, themeUrl);
}; };
export const deleteTheme = async (themeName) => { export const deleteTheme = async (themeName) => {
console.log(`Deleting theme ${themeName}...`); console.log(`Deleting theme ${themeName}...`);
const currentTheme = await localforage.getItem("selectedTheme");
if (currentTheme === themeName) {
await disableTheme();
}
await localforage.removeItem(`css_${themeName}`); await localforage.removeItem(`css_${themeName}`);
await Promise.all( await Promise.all(
(await localforage.keys()).filter((key) => key.startsWith(`images_${themeName}`)).map((key) => localforage.removeItem(key)) (await localforage.keys()).filter((key) => key.startsWith(`images_${themeName}`)).map((key) => localforage.removeItem(key))