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()) onMount(async () => await loadMore())
function nestComments(commentList) { const nestComments = (commentList) => {
const commentMap = {} const commentMap = {}
commentList.forEach((comment) => { commentList.forEach((comment) => {
commentMap[comment.id] = comment commentMap[comment.id] = comment
if (comment.replyTo) { if (comment.replyTo !== null) {
if (!comment.replyTo) return const parent = commentMap[comment.replyTo] ?? []
const parent = commentMap[comment.replyTo]
;(parent.children = parent.children || []).push(comment) ;(parent.children = parent.children || []).push(comment)
} }
}) })
@ -69,10 +68,6 @@ export const CommentsTree = (props: { shoutSlug: string }) => {
}) })
} }
createEffect(() => {
console.log('!!! reactions():', nestComments(reactions()))
})
return ( return (
<> <>
<Show when={!isCommentsLoading()} fallback={<Loading />}> <Show when={!isCommentsLoading()} fallback={<Loading />}>