fix vine comments and toast visibility

- ComposeBox: invalidate the correct 'event-comments' cache key after
  posting a NIP-22 comment so CommentsSheet refreshes immediately
- toast: raise z-index to 300 so it renders above the CommentsSheet
  backdrop blur (which sits at z-200)
This commit is contained in:
Chad Curtis
2026-03-03 00:45:31 -06:00
parent 09271be935
commit 64c9936014
4 changed files with 15 additions and 27 deletions
+4 -2
View File
@@ -860,9 +860,11 @@ export function ComposeBox({
queryClient.invalidateQueries({ queryKey: ['nostr', 'comments'] });
} else {
queryClient.invalidateQueries({ queryKey: ['replies', replyTo.id] });
// Also invalidate NIP-22 comments cache for non-kind-1 events
// Invalidate the event-comments cache used by CommentsSheet
if (replyTo.kind !== 1) {
queryClient.invalidateQueries({ queryKey: ['nostr', 'comments'] });
const dTag = replyTo.tags.find(([n]) => n === 'd')?.[1] ?? '';
const aTag = `${replyTo.kind}:${replyTo.pubkey}:${dTag}`;
queryClient.invalidateQueries({ queryKey: ['event-comments', aTag] });
}
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ const ToastViewport = React.forwardRef<
<ToastPrimitives.Viewport
ref={ref}
className={cn(
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px] safe-area-top",
"fixed top-0 z-[300] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px] safe-area-top",
className
)}
{...props}
+10 -5
View File
@@ -1,13 +1,12 @@
import { useNostr } from '@nostrify/react';
import { useQuery } from '@tanstack/react-query';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useCurrentUser } from '@/hooks/useCurrentUser';
/**
* Returns the current user's repost event ID for a given event, if any.
*
* Optimistic updates (set by RepostMenu via setQueryData) flow through
* useQuery's reactive `data` automatically — no separate getQueryData check
* needed.
* Checks the optimistic cache first (set by RepostMenu on repost/unrepost),
* then falls back to querying the relay for the user's kind 6 or kind 16 events.
*
* Returns:
* - `undefined` while loading
@@ -17,6 +16,10 @@ import { useCurrentUser } from '@/hooks/useCurrentUser';
export function useRepostStatus(eventId: string | undefined): string | null | undefined {
const { nostr } = useNostr();
const { user } = useCurrentUser();
const queryClient = useQueryClient();
// Check optimistic cache first
const optimistic = queryClient.getQueryData<string | null>(['user-repost', eventId ?? '']);
const { data } = useQuery({
queryKey: ['user-repost', eventId ?? ''],
@@ -37,10 +40,12 @@ export function useRepostStatus(eventId: string | undefined): string | null | un
if (events.length === 0) return null;
return events[0].id;
},
enabled: !!eventId && !!user,
enabled: !!eventId && !!user && !optimistic,
staleTime: 5 * 60 * 1000,
gcTime: 10 * 60 * 1000,
});
// Prefer optimistic value, then query result
if (optimistic) return optimistic;
return data;
}
-19
View File
@@ -152,12 +152,6 @@ export function VineHeartButton({ event, label, noBackground }: { event: NostrEv
publishEvent(
{ kind: 7, content: '+', tags: [['e', event.id], ['p', event.pubkey], ['k', String(event.kind)]] },
{
onSuccess: () => {
setTimeout(() => {
queryClient.invalidateQueries({ queryKey: ['event-stats', event.id] });
queryClient.invalidateQueries({ queryKey: ['event-interactions', event.id] });
}, 3000);
},
onError: () => {
// Revert optimistic updates
if (prevStats) {
@@ -216,12 +210,6 @@ export function VineRepostButton({ event, label }: { event: NostrEvent; label?:
deleteEvent(
{ eventId: repostEventId, eventKind: repostKind },
{
onSuccess: () => {
setTimeout(() => {
queryClient.invalidateQueries({ queryKey: ['event-stats', event.id] });
queryClient.invalidateQueries({ queryKey: ['user-repost', event.id] });
}, 3000);
},
onError: () => {
if (prevStats) queryClient.setQueryData<EventStats>(['event-stats', event.id], prevStats);
queryClient.setQueryData(['user-repost', event.id], prevRepostStatus);
@@ -250,13 +238,6 @@ export function VineRepostButton({ event, label }: { event: NostrEvent; label?:
publishEvent(
{ kind: repostKind, content: '', tags },
{
onSuccess: () => {
setTimeout(() => {
queryClient.invalidateQueries({ queryKey: ['event-stats', event.id] });
queryClient.invalidateQueries({ queryKey: ['event-interactions', event.id] });
queryClient.invalidateQueries({ queryKey: ['user-repost', event.id] });
}, 3000);
},
onError: () => {
if (prevStats) queryClient.setQueryData<EventStats>(['event-stats', event.id], prevStats);
queryClient.setQueryData(['user-repost', event.id], null);