mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
save selectedColor for non-destructive theme viewing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
||||
import browser from 'webextension-polyfill';
|
||||
|
||||
|
||||
export const removeTheme = (theme: CustomTheme) => {
|
||||
export const removeTheme = async (theme: CustomTheme) => {
|
||||
// Remove custom CSS
|
||||
const styleElement = document.getElementById('custom-theme');
|
||||
if (styleElement) {
|
||||
@@ -9,7 +9,9 @@ export const removeTheme = (theme: CustomTheme) => {
|
||||
}
|
||||
|
||||
// Reset default color
|
||||
//browser.storage.local.set({ selectedColor: '' });
|
||||
const originalSelectedColor = await browser.storage.local.get('originalSelectedColor') as { originalSelectedColor: string; };
|
||||
await browser.storage.local.set({ selectedColor: originalSelectedColor.originalSelectedColor });
|
||||
|
||||
// Remove custom images
|
||||
const customImageVariables = theme.CustomImages.map((image) => image.variableName);
|
||||
customImageVariables.forEach((variableName) => {
|
||||
|
||||
@@ -20,8 +20,14 @@ export const setTheme = async (themeId: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
const originalSelectedColor = await browser.storage.local.get('selectedColor') as { selectedColor: string; };
|
||||
await applyTheme(theme);
|
||||
await browser.storage.local.set({ selectedTheme: themeId });
|
||||
|
||||
await browser.storage.local.set({
|
||||
selectedTheme: themeId,
|
||||
selectedColor: theme.defaultColour,
|
||||
originalSelectedColor: originalSelectedColor.selectedColor
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error setting theme:', error);
|
||||
|
||||
Reference in New Issue
Block a user