fix: comment expansions
This commit is contained in:
1 parent
57d4874990
commit
8c6ff77fac
3 files changed
+21
-9
No files matched your search
@@ -71,7 +71,13 @@
|
||||
data-index={row.index}
|
||||
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>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -45,8 +45,9 @@
|
||||
parent.comment_view.counts.child_count > 0 &&
|
||||
parent.children.length == 0
|
||||
)
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
parent.loading = true
|
||||
@@ -131,20 +132,22 @@
|
||||
href="/comment/{page.params.instance}/{node.comment_view.comment.id}"
|
||||
>
|
||||
<Button
|
||||
loading={node.loading}
|
||||
disabled={node.loading}
|
||||
loading={nodes[index].loading}
|
||||
disabled={nodes[index].loading}
|
||||
rounding="pill"
|
||||
color="tertiary"
|
||||
class="font-normal text-slate-600 dark:text-zinc-400"
|
||||
loaderWidth={16}
|
||||
onclick={() => {
|
||||
if (node.depth > 4) {
|
||||
if (nodes[index].depth > 4) {
|
||||
goto(
|
||||
`/comment/${page.params.instance}/${node.comment_view.comment.id}#comments`,
|
||||
`/comment/${page.params.instance}/${nodes[index].comment_view.comment.id}#comments`,
|
||||
)
|
||||
} else {
|
||||
node.loading = true
|
||||
fetchChildren(node).then(() => (node.loading = false))
|
||||
nodes[index].loading = true
|
||||
fetchChildren(nodes[index]).then(
|
||||
() => (nodes[index].loading = false),
|
||||
)
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -44,7 +44,10 @@
|
||||
let comments = $state(passedComments)
|
||||
|
||||
let commenting = $state(false)
|
||||
let tree = $derived(buildCommentsTree(comments.comments))
|
||||
let tree = $state(buildCommentsTree(comments.comments))
|
||||
$effect(() => {
|
||||
tree = buildCommentsTree(comments.comments)
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if $profile?.jwt}
|
||||
|
||||
Reference in new issue
Block a user