Include 'e' tag in active theme deletion events
Pass the event ID of the active profile theme to clearActiveTheme so the kind 5 deletion includes both an 'a' tag and an 'e' tag. Updated all call sites (ThemeSelector and EditProfileForm).
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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] });
|
||||
|
||||
Reference in New Issue
Block a user