add check

This commit is contained in:
ilya-bkv 2022-12-18 01:31:33 +03:00
parent a5ae274c3e
commit 7f0a902d04

View File

@ -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 (
<>
<Show when={!isCommentsLoading()} fallback={<Loading />}>