mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
save user preference theme color
This commit is contained in:
@@ -11,6 +11,7 @@ export type CustomTheme = {
|
|||||||
isEditable: boolean;
|
isEditable: boolean;
|
||||||
hideThemeName: boolean;
|
hideThemeName: boolean;
|
||||||
webURL?: string;
|
webURL?: string;
|
||||||
|
selectedColor?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DownloadedTheme = CustomTheme & {
|
export type DownloadedTheme = CustomTheme & {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import localforage from 'localforage';
|
||||||
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
|
|
||||||
@@ -8,6 +9,14 @@ export const removeTheme = async (theme: CustomTheme) => {
|
|||||||
styleElement.parentNode?.removeChild(styleElement);
|
styleElement.parentNode?.removeChild(styleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const themeSelectedColor = await browser.storage.local.get('selectedColor') as { selectedColor: string; };
|
||||||
|
|
||||||
|
const selectedTheme = await localforage.getItem(theme.id) as CustomTheme;
|
||||||
|
localforage.setItem(theme.id, {
|
||||||
|
...selectedTheme,
|
||||||
|
selectedColor: themeSelectedColor.selectedColor
|
||||||
|
})
|
||||||
|
|
||||||
// Reset default color
|
// Reset default color
|
||||||
const originalSelectedColor = await browser.storage.local.get('originalSelectedColor') as { originalSelectedColor: string; };
|
const originalSelectedColor = await browser.storage.local.get('originalSelectedColor') as { originalSelectedColor: string; };
|
||||||
if (originalSelectedColor.originalSelectedColor !== '') {
|
if (originalSelectedColor.originalSelectedColor !== '') {
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ export const setTheme = async (themeId: string) => {
|
|||||||
const enabledTheme = await browser.storage.local.get('selectedTheme') as { selectedTheme: string; };
|
const enabledTheme = await browser.storage.local.get('selectedTheme') as { selectedTheme: string; };
|
||||||
const theme = await localforage.getItem(themeId) as CustomTheme;
|
const theme = await localforage.getItem(themeId) as CustomTheme;
|
||||||
|
|
||||||
console.log(enabledTheme, theme)
|
|
||||||
|
|
||||||
console.debug('Loading theme', theme);
|
console.debug('Loading theme', theme);
|
||||||
|
|
||||||
let originalSelectedColor = { selectedColor: '' };
|
let originalSelectedColor = { selectedColor: '' };
|
||||||
@@ -34,7 +32,7 @@ export const setTheme = async (themeId: string) => {
|
|||||||
|
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
selectedTheme: themeId,
|
selectedTheme: themeId,
|
||||||
selectedColor: theme.defaultColour !== '' ? theme.defaultColour : '#007bff',
|
selectedColor: theme.selectedColor ? theme.selectedColor : (theme.defaultColour !== '' ? theme.defaultColour : '#007bff'),
|
||||||
originalSelectedColor: originalSelectedColor.selectedColor
|
originalSelectedColor: originalSelectedColor.selectedColor
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user