fix: comment expansions

This commit is contained in:
James Xylight committed 2025-02-07 13:54:03 -08:00
1 parent 57d4874990
commit 8c6ff77fac
3 files changed
+21 -9

No files matched your search

@@ -71,7 +71,13 @@
data-index={row.index} data-index={row.index}
class="-mx-4 sm:-mx-6 px-4 sm:px-6" class="-mx-4 sm:-mx-6 px-4 sm:px-6"
> >
<Comments isParent={true} nodes={[nodes[row.index]]} {post} /> <Comments
isParent={true}
bind:nodes={
() => [nodes[row.index]], (v) => (nodes[row.index] = v[0])
}
{post}
/>
</div> </div>
{/each} {/each}
</div> </div>
@@ -45,8 +45,9 @@
parent.comment_view.counts.child_count > 0 && parent.comment_view.counts.child_count > 0 &&
parent.children.length == 0 parent.children.length == 0
) )
) ) {
return return
}
try { try {
parent.loading = true parent.loading = true
@@ -131,20 +132,22 @@
href="/comment/{page.params.instance}/{node.comment_view.comment.id}" href="/comment/{page.params.instance}/{node.comment_view.comment.id}"
> >
<Button <Button
loading={node.loading} loading={nodes[index].loading}
disabled={node.loading} disabled={nodes[index].loading}
rounding="pill" rounding="pill"
color="tertiary" color="tertiary"
class="font-normal text-slate-600 dark:text-zinc-400" class="font-normal text-slate-600 dark:text-zinc-400"
loaderWidth={16} loaderWidth={16}
onclick={() => { onclick={() => {
if (node.depth > 4) { if (nodes[index].depth > 4) {
goto( goto(
`/comment/${page.params.instance}/${node.comment_view.comment.id}#comments`, `/comment/${page.params.instance}/${nodes[index].comment_view.comment.id}#comments`,
) )
} else { } else {
node.loading = true nodes[index].loading = true
fetchChildren(node).then(() => (node.loading = false)) fetchChildren(nodes[index]).then(
() => (nodes[index].loading = false),
)
} }
}} }}
> >
@@ -44,7 +44,10 @@
let comments = $state(passedComments) let comments = $state(passedComments)
let commenting = $state(false) let commenting = $state(false)
let tree = $derived(buildCommentsTree(comments.comments)) let tree = $state(buildCommentsTree(comments.comments))
$effect(() => {
tree = buildCommentsTree(comments.comments)
})
</script> </script>
{#if $profile?.jwt} {#if $profile?.jwt}