mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
auto load custom theme when saving
This commit is contained in:
@@ -76,7 +76,9 @@ export const saveTheme = async (theme: CustomThemeBase64) => {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('Theme to save:', updatedTheme)
|
disableTheme();
|
||||||
|
|
||||||
|
console.debug('Theme to save:', updatedTheme)
|
||||||
|
|
||||||
await localforage.setItem(updatedTheme.id, updatedTheme);
|
await localforage.setItem(updatedTheme.id, updatedTheme);
|
||||||
await localforage.getItem('customThemes').then((themes: unknown) => {
|
await localforage.getItem('customThemes').then((themes: unknown) => {
|
||||||
@@ -90,7 +92,7 @@ export const saveTheme = async (theme: CustomThemeBase64) => {
|
|||||||
localforage.setItem('customThemes', [updatedTheme.id]);
|
localforage.setItem('customThemes', [updatedTheme.id]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log('Theme saved successfully!');
|
console.debug('Theme saved successfully!');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving theme:', error);
|
console.error('Error saving theme:', error);
|
||||||
}
|
}
|
||||||
@@ -256,6 +258,8 @@ 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.debug('Loading theme', theme)
|
||||||
|
|
||||||
// Remove the currently enabled theme
|
// Remove the currently enabled theme
|
||||||
if (enabledTheme.selectedTheme) {
|
if (enabledTheme.selectedTheme) {
|
||||||
const currentTheme = await localforage.getItem(enabledTheme.selectedTheme) as CustomTheme;
|
const currentTheme = await localforage.getItem(enabledTheme.selectedTheme) as CustomTheme;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import browser from 'webextension-polyfill'
|
import browser from 'webextension-polyfill'
|
||||||
|
|
||||||
import { MenuOptionsOpen, OpenMenuOptions, OpenWhatsNewPopup, closeSettings } from '../../../SEQTA';
|
import { MenuOptionsOpen, OpenMenuOptions, OpenWhatsNewPopup, closeSettings } from '../../../SEQTA';
|
||||||
import { UpdateImageData, UpdateThemePreview, deleteTheme, disableTheme, getAvailableThemes, getTheme, saveTheme, setTheme } from '../../ui/Themes';
|
import { UpdateThemePreview, deleteTheme, disableTheme, getAvailableThemes, getTheme, saveTheme, setTheme } from '../../ui/Themes';
|
||||||
import { CloseThemeCreator, OpenThemeCreator } from '../../ui/ThemeCreator';
|
import { CloseThemeCreator, OpenThemeCreator } from '../../ui/ThemeCreator';
|
||||||
|
|
||||||
export class MessageHandler {
|
export class MessageHandler {
|
||||||
@@ -18,16 +18,18 @@ export class MessageHandler {
|
|||||||
|
|
||||||
case 'UpdateThemePreview':
|
case 'UpdateThemePreview':
|
||||||
if (request?.save == true) {
|
if (request?.save == true) {
|
||||||
saveTheme(request.body).then(() => {
|
const save = async () => {
|
||||||
setTheme(request.body.themeID).then(() => {
|
console.log('Saving theme:', request.body)
|
||||||
sendResponse({ status: 'success' });
|
await saveTheme(request.body)
|
||||||
});
|
await setTheme(request.body.id)
|
||||||
});
|
sendResponse({ status: 'success' });
|
||||||
|
}
|
||||||
|
save()
|
||||||
} else {
|
} else {
|
||||||
UpdateThemePreview(request.body);
|
UpdateThemePreview(request.body);
|
||||||
sendResponse({ status: 'success' });
|
sendResponse({ status: 'success' });
|
||||||
}
|
}
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case 'GetTheme':
|
case 'GetTheme':
|
||||||
getTheme(request.body.themeID).then((theme) => {
|
getTheme(request.body.themeID).then((theme) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user