diff --git a/src/components/EditProfileForm.tsx b/src/components/EditProfileForm.tsx index cef48482..fe6d7840 100644 --- a/src/components/EditProfileForm.tsx +++ b/src/components/EditProfileForm.tsx @@ -500,7 +500,7 @@ function ShareThemeSection() { } else { try { setIsDeleting(true); - await clearActiveTheme(); + await clearActiveTheme(activeThemeQuery.data?.event.id); activeThemeQuery.refetch(); toast({ title: 'Theme removed', description: 'Your profile theme is no longer shared.' }); } catch (error) { diff --git a/src/components/ThemeSelector.tsx b/src/components/ThemeSelector.tsx index 72e4dc8e..ac526d6d 100644 --- a/src/components/ThemeSelector.tsx +++ b/src/components/ThemeSelector.tsx @@ -121,7 +121,7 @@ export function ThemeSelector() { await setActiveTheme({ colors }); toast({ title: 'Theme shared', description: 'Your theme is now visible on your profile.' }); } else { - await clearActiveTheme(); + await clearActiveTheme(activeProfileTheme.data?.event.id); toast({ title: 'Theme hidden', description: 'Your theme is no longer visible on your profile.' }); } } catch { diff --git a/src/hooks/usePublishTheme.ts b/src/hooks/usePublishTheme.ts index ff7b8b9b..2d155831 100644 --- a/src/hooks/usePublishTheme.ts +++ b/src/hooks/usePublishTheme.ts @@ -98,16 +98,21 @@ export function usePublishTheme() { }, [user, publishEvent, queryClient]); /** Clear the active profile theme (kind 5 deletion of kind 11667). */ - const clearActiveTheme = useCallback(async () => { + const clearActiveTheme = useCallback(async (eventId?: string) => { if (!user) throw new Error('Must be logged in'); + const tags: string[][] = [ + ['a', `${ACTIVE_THEME_KIND}:${user.pubkey}:`], + ['k', String(ACTIVE_THEME_KIND)], + ]; + if (eventId) { + tags.push(['e', eventId]); + } + await publishEvent({ kind: 5, content: '', - tags: [ - ['a', `${ACTIVE_THEME_KIND}:${user.pubkey}:`], - ['k', String(ACTIVE_THEME_KIND)], - ], + tags, }); queryClient.invalidateQueries({ queryKey: ['activeProfileTheme', user.pubkey] });