fix: only a few comments load when changing sort
This commit is contained in:
1 parent
dff48fa213
commit
b1b9486d3e
3 files changed
+3
-40
No files matched your search
@@ -46,11 +46,12 @@
|
|||||||
|
|
||||||
data.streamed.comments = getClient().getComments({
|
data.streamed.comments = getClient().getComments({
|
||||||
auth: $profile?.jwt,
|
auth: $profile?.jwt,
|
||||||
page: commentsPage,
|
page: 1,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
type_: 'All',
|
type_: 'All',
|
||||||
post_id: data.post.post_view.post.id,
|
post_id: data.post.post_view.post.id,
|
||||||
sort: commentSort,
|
sort: commentSort,
|
||||||
|
max_depth: 3,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -187,41 +188,6 @@
|
|||||||
{:then comments}
|
{:then comments}
|
||||||
<Comments {post} nodes={comments} isParent={true} />
|
<Comments {post} nodes={comments} isParent={true} />
|
||||||
{/await}
|
{/await}
|
||||||
{#if moreComments}
|
|
||||||
<Button
|
|
||||||
{loading}
|
|
||||||
disabled={loading}
|
|
||||||
color="tertiary"
|
|
||||||
on:click={async () => {
|
|
||||||
if (!moreComments) return
|
|
||||||
loading = true
|
|
||||||
|
|
||||||
const loadedComments = await getClient().getComments({
|
|
||||||
auth: $profile?.jwt,
|
|
||||||
max_depth: 3,
|
|
||||||
page: ++commentsPage,
|
|
||||||
limit: 25,
|
|
||||||
type_: 'All',
|
|
||||||
post_id: data.post.post_view.post.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (comments.comments == loadedComments.comments) {
|
|
||||||
comments.comments = [
|
|
||||||
...comments.comments,
|
|
||||||
...loadedComments.comments.filter(
|
|
||||||
(comment) => !comments.comments.includes(comment)
|
|
||||||
),
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
moreComments = false
|
|
||||||
}
|
|
||||||
|
|
||||||
loading = false
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Load more
|
|
||||||
</Button>
|
|
||||||
{/if}
|
|
||||||
{:catch}
|
{:catch}
|
||||||
<div class="bg-red-500/10 border border-red-500 rounded-md p-4">
|
<div class="bg-red-500/10 border border-red-500 rounded-md p-4">
|
||||||
Failed to load comments.
|
Failed to load comments.
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export async function load({ params, url, fetch }) {
|
|||||||
comments: getClient(params.instance.toLowerCase(), fetch).getComments({
|
comments: getClient(params.instance.toLowerCase(), fetch).getComments({
|
||||||
post_id: Number(params.id),
|
post_id: Number(params.id),
|
||||||
type_: 'All',
|
type_: 'All',
|
||||||
limit: 25,
|
limit: 50,
|
||||||
page: 1,
|
page: 1,
|
||||||
max_depth: max_depth,
|
max_depth: max_depth,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ export default defineConfig({
|
|||||||
SvelteKitPWA({
|
SvelteKitPWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
strategies: 'generateSW',
|
strategies: 'generateSW',
|
||||||
workbox: {
|
|
||||||
globPatterns: ['client/**/*.{js,css,html,ico,png,svg}'],
|
|
||||||
},
|
|
||||||
devOptions: {
|
devOptions: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
type: 'module',
|
type: 'module',
|
||||||
|
|||||||
Reference in new issue
Block a user