diff --git a/src/interface/types/CustomThemes.ts b/src/interface/types/CustomThemes.ts index 69d6d134..821b104c 100644 --- a/src/interface/types/CustomThemes.ts +++ b/src/interface/types/CustomThemes.ts @@ -11,6 +11,7 @@ export type CustomTheme = { isEditable: boolean; hideThemeName: boolean; webURL?: string; + selectedColor?: string; } export type DownloadedTheme = CustomTheme & { diff --git a/src/seqta/ui/themes/removeTheme.ts b/src/seqta/ui/themes/removeTheme.ts index 733eceae..56a4c671 100644 --- a/src/seqta/ui/themes/removeTheme.ts +++ b/src/seqta/ui/themes/removeTheme.ts @@ -1,3 +1,4 @@ +import localforage from 'localforage'; import { CustomTheme } from '../../../interface/types/CustomThemes'; import browser from 'webextension-polyfill'; @@ -8,6 +9,14 @@ export const removeTheme = async (theme: CustomTheme) => { 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 const originalSelectedColor = await browser.storage.local.get('originalSelectedColor') as { originalSelectedColor: string; }; if (originalSelectedColor.originalSelectedColor !== '') { diff --git a/src/seqta/ui/themes/setTheme.ts b/src/seqta/ui/themes/setTheme.ts index 0fa3fc99..1355e768 100644 --- a/src/seqta/ui/themes/setTheme.ts +++ b/src/seqta/ui/themes/setTheme.ts @@ -10,8 +10,6 @@ export const setTheme = async (themeId: string) => { const enabledTheme = await browser.storage.local.get('selectedTheme') as { selectedTheme: string; }; const theme = await localforage.getItem(themeId) as CustomTheme; - console.log(enabledTheme, theme) - console.debug('Loading theme', theme); let originalSelectedColor = { selectedColor: '' }; @@ -34,7 +32,7 @@ export const setTheme = async (themeId: string) => { await browser.storage.local.set({ selectedTheme: themeId, - selectedColor: theme.defaultColour !== '' ? theme.defaultColour : '#007bff', + selectedColor: theme.selectedColor ? theme.selectedColor : (theme.defaultColour !== '' ? theme.defaultColour : '#007bff'), originalSelectedColor: originalSelectedColor.selectedColor });