auto load custom theme when saving

This commit is contained in:
SethBurkart123
2024-04-04 10:28:46 +11:00
parent 3cca05535a
commit dc08934eeb
2 changed files with 15 additions and 9 deletions
+6 -2
View File
@@ -76,7 +76,9 @@ export const saveTheme = async (theme: CustomThemeBase64) => {
),
};
console.log('Theme to save:', updatedTheme)
disableTheme();
console.debug('Theme to save:', updatedTheme)
await localforage.setItem(updatedTheme.id, updatedTheme);
await localforage.getItem('customThemes').then((themes: unknown) => {
@@ -90,7 +92,7 @@ export const saveTheme = async (theme: CustomThemeBase64) => {
localforage.setItem('customThemes', [updatedTheme.id]);
}
});
console.log('Theme saved successfully!');
console.debug('Theme saved successfully!');
} catch (error) {
console.error('Error saving theme:', error);
}
@@ -256,6 +258,8 @@ export const setTheme = async (themeId: string) => {
const enabledTheme = await browser.storage.local.get('selectedTheme') as { selectedTheme: string };
const theme = await localforage.getItem(themeId) as CustomTheme;
console.debug('Loading theme', theme)
// Remove the currently enabled theme
if (enabledTheme.selectedTheme) {
const currentTheme = await localforage.getItem(enabledTheme.selectedTheme) as CustomTheme;