fix: 🐛

This commit is contained in:
codytseng
2025-05-16 15:49:27 +08:00
parent 81b6462b63
commit 12f5d41811
2 changed files with 15 additions and 2 deletions

View File

@@ -31,7 +31,21 @@ export default function ReplyNoteList({
const { currentIndex } = useSecondaryPage()
const [rootInfo, setRootInfo] = useState<{ id: string; pubkey: string } | undefined>(undefined)
const { repliesMap, addReplies } = useReply()
const replies = useMemo(() => repliesMap.get(event.id)?.events || [], [event.id, repliesMap])
const replies = useMemo(() => {
const replyIdSet = new Set<string>()
const replyEvents: NEvent[] = []
let parentEventIds = [event.id]
while (parentEventIds.length > 0) {
const events = parentEventIds.flatMap((id) => repliesMap.get(id)?.events || [])
events.forEach((evt) => {
if (replyIdSet.has(evt.id)) return
replyIdSet.add(evt.id)
replyEvents.push(evt)
})
parentEventIds = events.map((evt) => evt.id)
}
return replyEvents.sort((a, b) => a.created_at - b.created_at)
}, [event.id, repliesMap])
const [timelineKey, setTimelineKey] = useState<string | undefined>(undefined)
const [until, setUntil] = useState<number | undefined>(undefined)
const [loading, setLoading] = useState<boolean>(false)

View File

@@ -50,7 +50,6 @@ export function ReplyProvider({ children }: { children: React.ReactNode }) {
replies.eventIdSet.add(reply.id)
}
})
replies.events.sort((a, b) => a.created_at - b.created_at)
prev.set(id, replies)
}
return new Map(prev)