mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
separate thems into separate files
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import browser from 'webextension-polyfill';
|
||||
import localforage from 'localforage';
|
||||
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
||||
import { applyTheme } from './applyTheme';
|
||||
import { removeTheme } from './removeTheme';
|
||||
|
||||
|
||||
export const setTheme = async (themeId: string) => {
|
||||
try {
|
||||
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;
|
||||
if (currentTheme) {
|
||||
removeTheme(currentTheme);
|
||||
}
|
||||
}
|
||||
|
||||
await applyTheme(theme);
|
||||
await browser.storage.local.set({ selectedTheme: themeId });
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error setting theme:', error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user