Skip to content

Commit

Permalink
fix: comment expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyphyn committed Feb 7, 2025
1 parent 57d4874 commit 8c6ff77
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
17 changes: 10 additions & 7 deletions src/lib/components/lemmy/comment/Comments.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
parent.comment_view.counts.child_count > 0 &&
parent.children.length == 0
)
)
) {
return
}
try {
parent.loading = true
Expand Down Expand Up @@ -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),
)
}
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 8c6ff77

Please sign in to comment.