Fix threaded replies: only show first child inline, hide siblings
The linear threading UI (connector lines) only works for single chains. When a reply had multiple children, siblings after the first rendered without any visual connection to their parent, making them look like top-level replies. Fix by only including the first child in each node's thread chain — additional siblings are hidden since there is no UI to display branching threads.
This commit is contained in:
@@ -1184,18 +1184,24 @@ function PostDetailContent({ event }: { event: NostrEvent }) {
|
||||
}
|
||||
}
|
||||
|
||||
const buildNode = (ev: NostrEvent): ReplyNode => ({
|
||||
event: ev,
|
||||
children: (childrenMap.get(ev.id) ?? []).map(buildNode),
|
||||
});
|
||||
const buildNode = (ev: NostrEvent): ReplyNode => {
|
||||
const firstChild = (childrenMap.get(ev.id) ?? [])[0];
|
||||
return {
|
||||
event: ev,
|
||||
children: firstChild ? [buildNode(firstChild)] : [],
|
||||
};
|
||||
};
|
||||
return directReplies.map(buildNode);
|
||||
}
|
||||
|
||||
// Kind 1111 or non-kind-1 root: use NIP-22 comment structure
|
||||
const buildNode = (ev: NostrEvent): ReplyNode => ({
|
||||
event: ev,
|
||||
children: (commentsData?.getDirectReplies(ev.id) ?? []).map(buildNode),
|
||||
});
|
||||
const buildNode = (ev: NostrEvent): ReplyNode => {
|
||||
const firstChild = (commentsData?.getDirectReplies(ev.id) ?? [])[0];
|
||||
return {
|
||||
event: ev,
|
||||
children: firstChild ? [buildNode(firstChild)] : [],
|
||||
};
|
||||
};
|
||||
|
||||
if (isComment) {
|
||||
const directReplies = commentsData?.getDirectReplies(event.id) ?? [];
|
||||
|
||||
Reference in New Issue
Block a user