mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
fix(ThemeCreator): saving and editing with images not working
This commit is contained in:
@@ -8,20 +8,19 @@ export const saveTheme = async (theme: LoadedCustomTheme) => {
|
|||||||
disableTheme();
|
disableTheme();
|
||||||
|
|
||||||
console.debug('Theme to save:', theme);
|
console.debug('Theme to save:', theme);
|
||||||
|
|
||||||
/* remove blob urls from theme */
|
|
||||||
const updatedTheme = { ...theme, CustomImages: theme.CustomImages.map((image) => ({ ...image, blob: null })) }
|
|
||||||
|
|
||||||
await localforage.setItem(theme.id, updatedTheme);
|
console.log('stage 1')
|
||||||
|
await localforage.setItem(theme.id, theme);
|
||||||
|
console.log('stage 2')
|
||||||
await localforage.getItem('customThemes').then((themes: unknown) => {
|
await localforage.getItem('customThemes').then((themes: unknown) => {
|
||||||
const themeList = themes as string[] | null;
|
const themeList = themes as string[] | null;
|
||||||
if (themeList) {
|
if (themeList) {
|
||||||
if (!themeList.includes(updatedTheme.id)) {
|
if (!themeList.includes(theme.id)) {
|
||||||
themeList.push(updatedTheme.id);
|
themeList.push(theme.id);
|
||||||
localforage.setItem('customThemes', themeList);
|
localforage.setItem('customThemes', themeList);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
localforage.setItem('customThemes', [updatedTheme.id]);
|
localforage.setItem('customThemes', [theme.id]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.debug('Theme saved successfully!');
|
console.debug('Theme saved successfully!');
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
import { ClearThemePreview, UpdateThemePreview } from '@/seqta/ui/themes/UpdateThemePreview'
|
import { ClearThemePreview, UpdateThemePreview } from '@/seqta/ui/themes/UpdateThemePreview'
|
||||||
import { saveTheme } from '@/seqta/ui/themes/saveTheme'
|
import { saveTheme } from '@/seqta/ui/themes/saveTheme'
|
||||||
import { CloseThemeCreator } from '@/seqta/ui/ThemeCreator'
|
import { CloseThemeCreator } from '@/seqta/ui/ThemeCreator'
|
||||||
|
import { themeUpdates } from '../hooks/ThemeUpdates'
|
||||||
|
|
||||||
const { themeID } = $props<{ themeID: string }>()
|
const { themeID } = $props<{ themeID: string }>()
|
||||||
let theme = $state<LoadedCustomTheme>({
|
let theme = $state<LoadedCustomTheme>({
|
||||||
@@ -88,9 +89,18 @@
|
|||||||
|
|
||||||
function submitTheme() {
|
function submitTheme() {
|
||||||
console.log('saving theme', theme)
|
console.log('saving theme', theme)
|
||||||
|
const themeClone = JSON.parse(JSON.stringify(theme));
|
||||||
|
|
||||||
|
// re-insert blobs into themeClone
|
||||||
|
themeClone.CustomImages = theme.CustomImages.map((image) => ({
|
||||||
|
...image,
|
||||||
|
blob: image.blob
|
||||||
|
}))
|
||||||
|
themeClone.coverImage = theme.coverImage
|
||||||
|
|
||||||
ClearThemePreview();
|
ClearThemePreview();
|
||||||
saveTheme(theme);
|
saveTheme(themeClone);
|
||||||
|
themeUpdates.triggerUpdate();
|
||||||
CloseThemeCreator();
|
CloseThemeCreator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user