diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx index f786fb00..1d548c4a 100644 --- a/src/components/Article/CommentsTree.tsx +++ b/src/components/Article/CommentsTree.tsx @@ -54,13 +54,12 @@ export const CommentsTree = (props: { shoutSlug: string }) => { } onMount(async () => await loadMore()) - function nestComments(commentList) { + const nestComments = (commentList) => { const commentMap = {} commentList.forEach((comment) => { commentMap[comment.id] = comment - if (comment.replyTo) { - if (!comment.replyTo) return - const parent = commentMap[comment.replyTo] + if (comment.replyTo !== null) { + const parent = commentMap[comment.replyTo] ?? [] ;(parent.children = parent.children || []).push(comment) } }) @@ -69,10 +68,6 @@ export const CommentsTree = (props: { shoutSlug: string }) => { }) } - createEffect(() => { - console.log('!!! reactions():', nestComments(reactions())) - }) - return ( <> }>