From 187a817b8a8ebe997da668d0aa6fd7bdc45d39cf Mon Sep 17 00:00:00 2001 From: Silberengel Date: Wed, 12 Nov 2025 22:56:33 +0100 Subject: [PATCH] auto-refresh replies --- src/components/ReplyNoteList/index.tsx | 10 +++++++++- src/providers/NostrProvider/index.tsx | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/ReplyNoteList/index.tsx b/src/components/ReplyNoteList/index.tsx index a389e35..7c27b33 100644 --- a/src/components/ReplyNoteList/index.tsx +++ b/src/components/ReplyNoteList/index.tsx @@ -233,7 +233,15 @@ function ReplyNoteList({ index, event, sort = 'oldest' }: { index?: number; even const onNewReply = useCallback((evt: NEvent) => { addReplies([evt]) - }, []) + // Also update the discussion cache so the reply persists + if (rootInfo) { + const cachedReplies = discussionFeedCache.getCachedReplies(rootInfo) || [] + const existingReplyIds = new Set(cachedReplies.map(r => r.id)) + if (!existingReplyIds.has(evt.id)) { + discussionFeedCache.setCachedReplies(rootInfo, [...cachedReplies, evt]) + } + } + }, [addReplies, rootInfo]) useEffect(() => { if (!rootInfo) return diff --git a/src/providers/NostrProvider/index.tsx b/src/providers/NostrProvider/index.tsx index 45b0f58..68afd27 100644 --- a/src/providers/NostrProvider/index.tsx +++ b/src/providers/NostrProvider/index.tsx @@ -932,6 +932,10 @@ export function NostrProvider({ children }: { children: React.ReactNode }) { }, 100) } + // Emit newEvent immediately after publishing so UI components can react + // This ensures replies appear immediately in the note view + client.emitNewEvent(event) + console.log('✅ [Publish] Returning event', { eventId: event.id?.substring(0, 8), hasRelayStatuses: !!relayStatuses }) return event } catch (error) {