separate thems into separate files

This commit is contained in:
SethBurkart123
2024-04-05 09:36:59 +11:00
parent 38c31b88e6
commit f1346ab86e
15 changed files with 340 additions and 295 deletions
+23
View File
@@ -0,0 +1,23 @@
import browser from 'webextension-polyfill';
import localforage from 'localforage';
import { CustomTheme } from '../../../interface/types/CustomThemes';
import { removeTheme } from './removeTheme';
export const deleteTheme = async (themeId: string) => {
try {
const theme = await localforage.getItem(themeId) as CustomTheme;
removeTheme(theme);
await localforage.removeItem(themeId);
const themeIds = await localforage.getItem('customThemes') as string[] | null;
if (themeIds) {
const updatedThemeIds = themeIds.filter((id) => id !== themeId);
await localforage.setItem('customThemes', updatedThemeIds);
}
await browser.storage.local.set({ selectedTheme: '' });
} catch (error) {
console.error('Error deleting theme:', error);
}
};