DRY up wall and reply rendering with ThreadedReplyList component
Extract shared ThreadedReplyList component and use it in PostDetailPage, ExternalContentPage, and ProfilePage wall tab. Wall comments now also fetch sub-replies via useComments so they render with the same threaded/threadedLast connector-line pairing as replies.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { NostrEvent } from '@nostrify/nostrify';
|
||||
import { NoteCard } from '@/components/NoteCard';
|
||||
|
||||
export interface ThreadedReply {
|
||||
reply: NostrEvent;
|
||||
firstSubReply?: NostrEvent;
|
||||
}
|
||||
|
||||
interface ThreadedReplyListProps {
|
||||
replies: ThreadedReply[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a flat list of replies where each top-level reply is optionally
|
||||
* followed by its first sub-reply, using NoteCard's threaded/threadedLast
|
||||
* connector-line styling for visual continuity.
|
||||
*/
|
||||
export function ThreadedReplyList({ replies }: ThreadedReplyListProps) {
|
||||
return (
|
||||
<>
|
||||
{replies.map(({ reply, firstSubReply }) => (
|
||||
<div key={reply.id}>
|
||||
<NoteCard event={reply} threaded={!!firstSubReply} />
|
||||
{firstSubReply && (
|
||||
<NoteCard event={firstSubReply} threadedLast />
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user