mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 11:44:40 +00:00
fix(ThemeCreator): coverimage not loading on edit
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import localforage from 'localforage';
|
import localforage from 'localforage';
|
||||||
import type { CustomTheme } from '@/types/CustomThemes';
|
import type { LoadedCustomTheme } from '@/types/CustomThemes';
|
||||||
|
|
||||||
|
|
||||||
export const getTheme = async (themeId: string): Promise<CustomTheme | null> => {
|
export const getTheme = async (themeId: string): Promise<LoadedCustomTheme | null> => {
|
||||||
try {
|
try {
|
||||||
const theme = await localforage.getItem(themeId) as CustomTheme;
|
const theme = await localforage.getItem(themeId) as LoadedCustomTheme;
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import localforage from 'localforage';
|
import localforage from 'localforage';
|
||||||
import type { LoadedCustomTheme } from '@/types/CustomThemes';
|
import type { LoadedCustomTheme } from '@/types/CustomThemes';
|
||||||
import { disableTheme } from './disableTheme';
|
import { disableTheme } from './disableTheme';
|
||||||
|
import { themeUpdates } from '@/svelte-interface/hooks/ThemeUpdates';
|
||||||
|
|
||||||
|
|
||||||
export const saveTheme = async (theme: LoadedCustomTheme) => {
|
export const saveTheme = async (theme: LoadedCustomTheme) => {
|
||||||
@@ -9,9 +10,7 @@ export const saveTheme = async (theme: LoadedCustomTheme) => {
|
|||||||
|
|
||||||
console.debug('Theme to save:', theme);
|
console.debug('Theme to save:', theme);
|
||||||
|
|
||||||
console.log('stage 1')
|
|
||||||
await localforage.setItem(theme.id, theme);
|
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) {
|
||||||
@@ -24,6 +23,7 @@ export const saveTheme = async (theme: LoadedCustomTheme) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.debug('Theme saved successfully!');
|
console.debug('Theme saved successfully!');
|
||||||
|
themeUpdates.triggerUpdate();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving theme:', error);
|
console.error('Error saving theme:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,8 +143,8 @@
|
|||||||
{#if !isEditMode}
|
{#if !isEditMode}
|
||||||
<div
|
<div
|
||||||
class="absolute z-20 flex w-8 h-8 p-2 text-white transition-all rounded-full delay-[20ms] opacity-0 top-1/4 right-2 bg-black/50 place-items-center group-hover:opacity-100 group-hover:top-1/2 -translate-y-1/2"
|
class="absolute z-20 flex w-8 h-8 p-2 text-white transition-all rounded-full delay-[20ms] opacity-0 top-1/4 right-2 bg-black/50 place-items-center group-hover:opacity-100 group-hover:top-1/2 -translate-y-1/2"
|
||||||
onclick={(event) => { event.stopPropagation(); OpenThemeCreator(theme.id) }}
|
onclick={(event) => { event.stopPropagation(); OpenThemeCreator(theme.id); closeExtensionPopup() }}
|
||||||
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') OpenThemeCreator(theme.id) }}
|
onkeydown={(event) => { if (event.key === 'Enter' || event.key === ' ') OpenThemeCreator(theme.id); closeExtensionPopup() }}
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
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'
|
import { themeUpdates } from '../hooks/ThemeUpdates'
|
||||||
|
import { disableTheme } from '@/seqta/ui/themes/disableTheme'
|
||||||
|
|
||||||
const { themeID } = $props<{ themeID: string }>()
|
const { themeID } = $props<{ themeID: string }>()
|
||||||
let theme = $state<LoadedCustomTheme>({
|
let theme = $state<LoadedCustomTheme>({
|
||||||
@@ -54,6 +55,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
disableTheme();
|
||||||
|
|
||||||
if (themeID) {
|
if (themeID) {
|
||||||
const tempTheme = await getTheme(themeID)
|
const tempTheme = await getTheme(themeID)
|
||||||
|
|
||||||
@@ -65,7 +68,8 @@
|
|||||||
CustomImages: tempTheme.CustomImages.map(image => ({
|
CustomImages: tempTheme.CustomImages.map(image => ({
|
||||||
...image,
|
...image,
|
||||||
url: image.blob ? URL.createObjectURL(image.blob) : null
|
url: image.blob ? URL.createObjectURL(image.blob) : null
|
||||||
}))
|
})),
|
||||||
|
coverImageUrl: tempTheme.coverImage ? URL.createObjectURL(tempTheme.coverImage) : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempTheme) {
|
if (tempTheme) {
|
||||||
@@ -75,6 +79,8 @@
|
|||||||
} else {
|
} else {
|
||||||
themeLoaded = true
|
themeLoaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
themeUpdates.triggerUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onImageUpload(event: Event) {
|
async function onImageUpload(event: Event) {
|
||||||
@@ -94,7 +100,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitTheme() {
|
function submitTheme() {
|
||||||
console.log('saving theme', theme)
|
|
||||||
const themeClone = JSON.parse(JSON.stringify(theme));
|
const themeClone = JSON.parse(JSON.stringify(theme));
|
||||||
|
|
||||||
// re-insert blobs into themeClone
|
// re-insert blobs into themeClone
|
||||||
|
|||||||
Reference in New Issue
Block a user