fix: view wont update on new comments, close #611
This commit is contained in:
2 files changed
+7
-7
No files matched your search
@@ -31,6 +31,7 @@
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly } from 'svelte/transition'
|
||||
import CommentProvider from './CommentProvider.svelte'
|
||||
import { ReactiveState } from '$lib/promise.svelte'
|
||||
|
||||
let { data } = $props()
|
||||
|
||||
@@ -261,16 +262,17 @@
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:then comments}
|
||||
{:then passedComments}
|
||||
{@const comments = new ReactiveState(passedComments)}
|
||||
<CommentProvider
|
||||
{comments}
|
||||
comments={comments.value}
|
||||
post={data.post.value}
|
||||
focus={data.thread.value.focus}
|
||||
onupdate={reloadComments}
|
||||
bind:sort={data.commentSort.value}
|
||||
virtualize={!page.url.searchParams.get('noVirtualize')}
|
||||
/>
|
||||
{#if comments.comments.length == 0}
|
||||
{#if comments.value.comments.length == 0}
|
||||
<Placeholder
|
||||
icon={ChatBubbleLeftRight}
|
||||
title={$t('routes.post.emptyComments.title')}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
let {
|
||||
post,
|
||||
comments: passedComments,
|
||||
comments,
|
||||
sort = $bindable(),
|
||||
onupdate,
|
||||
focus,
|
||||
@@ -46,8 +46,6 @@
|
||||
}: Props = $props()
|
||||
let commenting = $state(false)
|
||||
|
||||
let comments = $derived(passedComments)
|
||||
|
||||
let tree = $state(buildCommentsTree(comments.comments))
|
||||
$effect(() => {
|
||||
tree = buildCommentsTree(comments.comments)
|
||||
@@ -120,7 +118,7 @@
|
||||
<CommentForm
|
||||
postId={post.post_view.post.id}
|
||||
oncomment={comment => {
|
||||
comments.comments.push(comment.comment_view)
|
||||
comments.comments.unshift(comment.comment_view)
|
||||
}}
|
||||
onfocus={() => (commenting = true)}
|
||||
tools={commenting}
|
||||
|
||||
Reference in new issue
Block a user