Browse Source

auto-refresh replies

imwald
Silberengel 4 months ago
parent
commit
187a817b8a
  1. 10
      src/components/ReplyNoteList/index.tsx
  2. 4
      src/providers/NostrProvider/index.tsx

10
src/components/ReplyNoteList/index.tsx

@ -233,7 +233,15 @@ function ReplyNoteList({ index, event, sort = 'oldest' }: { index?: number; even
const onNewReply = useCallback((evt: NEvent) => { const onNewReply = useCallback((evt: NEvent) => {
addReplies([evt]) 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(() => { useEffect(() => {
if (!rootInfo) return if (!rootInfo) return

4
src/providers/NostrProvider/index.tsx

@ -932,6 +932,10 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
}, 100) }, 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 }) console.log('✅ [Publish] Returning event', { eventId: event.id?.substring(0, 8), hasRelayStatuses: !!relayStatuses })
return event return event
} catch (error) { } catch (error) {

Loading…
Cancel
Save