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:
@@ -173,6 +173,7 @@ const DefaultValues: SettingsState = {
|
|||||||
subjectfilters: {},
|
subjectfilters: {},
|
||||||
selectedTheme: '',
|
selectedTheme: '',
|
||||||
selectedColor: 'linear-gradient(40deg, rgba(201,61,0,1) 0%, RGBA(170, 5, 58, 1) 100%)',
|
selectedColor: 'linear-gradient(40deg, rgba(201,61,0,1) 0%, RGBA(170, 5, 58, 1) 100%)',
|
||||||
|
originalSelectedColor: '',
|
||||||
DarkMode: true,
|
DarkMode: true,
|
||||||
shortcuts: [
|
shortcuts: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
||||||
|
import browser from 'webextension-polyfill';
|
||||||
|
|
||||||
|
export const removeTheme = async (theme: CustomTheme) => {
|
||||||
export const removeTheme = (theme: CustomTheme) => {
|
|
||||||
// Remove custom CSS
|
// Remove custom CSS
|
||||||
const styleElement = document.getElementById('custom-theme');
|
const styleElement = document.getElementById('custom-theme');
|
||||||
if (styleElement) {
|
if (styleElement) {
|
||||||
@@ -9,7 +9,9 @@ export const removeTheme = (theme: CustomTheme) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reset default color
|
// 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
|
// Remove custom images
|
||||||
const customImageVariables = theme.CustomImages.map((image) => image.variableName);
|
const customImageVariables = theme.CustomImages.map((image) => image.variableName);
|
||||||
customImageVariables.forEach((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 applyTheme(theme);
|
||||||
await browser.storage.local.set({ selectedTheme: themeId });
|
|
||||||
|
await browser.storage.local.set({
|
||||||
|
selectedTheme: themeId,
|
||||||
|
selectedColor: theme.defaultColour,
|
||||||
|
originalSelectedColor: originalSelectedColor.selectedColor
|
||||||
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error setting theme:', error);
|
console.error('Error setting theme:', error);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface SettingsState {
|
|||||||
telemetry: boolean;
|
telemetry: boolean;
|
||||||
onoff: boolean;
|
onoff: boolean;
|
||||||
selectedColor: string;
|
selectedColor: string;
|
||||||
|
originalSelectedColor: string;
|
||||||
shortcuts: Shortcut[];
|
shortcuts: Shortcut[];
|
||||||
subjectfilters: Record<string, any>;
|
subjectfilters: Record<string, any>;
|
||||||
transparencyEffects: boolean;
|
transparencyEffects: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user