fix: only a few comments load when changing sort

This commit is contained in:
Xyphyn committed 2023-08-11 16:41:13 -07:00
1 parent dff48fa213
commit b1b9486d3e
3 files changed
+3 -40

No files matched your search

@@ -46,11 +46,12 @@
data.streamed.comments = getClient().getComments({
auth: $profile?.jwt,
page: commentsPage,
page: 1,
limit: 25,
type_: 'All',
post_id: data.post.post_view.post.id,
sort: commentSort,
max_depth: 3,
})
}
</script>
@@ -187,41 +188,6 @@
{:then comments}
<Comments {post} nodes={comments} isParent={true} />
{/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}
<div class="bg-red-500/10 border border-red-500 rounded-md p-4">
Failed to load comments.
@@ -37,7 +37,7 @@ export async function load({ params, url, fetch }) {
comments: getClient(params.instance.toLowerCase(), fetch).getComments({
post_id: Number(params.id),
type_: 'All',
limit: 25,
limit: 50,
page: 1,
max_depth: max_depth,
saved_only: false,
-3
View File
@@ -8,9 +8,6 @@ export default defineConfig({
SvelteKitPWA({
registerType: 'autoUpdate',
strategies: 'generateSW',
workbox: {
globPatterns: ['client/**/*.{js,css,html,ico,png,svg}'],
},
devOptions: {
enabled: true,
type: 'module',