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
+34
View File
@@ -0,0 +1,34 @@
import browser from 'webextension-polyfill';
import localforage from 'localforage';
import { CustomTheme, ThemeList } from '../../../interface/types/CustomThemes';
export const getAvailableThemes = async (): Promise<ThemeList | {}> => {
try {
const themeIds = await localforage.getItem('customThemes') as string[] | null;
console.log('Available themes:', themeIds);
if (themeIds) {
const themes = await Promise.all(
themeIds.map(async (id) => {
const theme = await localforage.getItem(id) as CustomTheme;
const { CustomImages, ...themeWithoutImages } = theme;
return themeWithoutImages;
})
);
const selectedTheme = await browser.storage.local.get('selectedTheme') as { selectedTheme: string; };
return { themes, selectedTheme: selectedTheme.selectedTheme ? selectedTheme.selectedTheme : '' };
}
return {
themes: [],
selectedTheme: '',
};
} catch (error) {
console.error('Error getting available themes:', error);
return {
themes: [],
selectedTheme: ''
};
}
};