feat: Add pagination to inbox page

This commit is contained in:
Xyphyn committed 2023-07-27 12:30:09 -07:00
1 parent c0aaf08a9f
commit 81270b72d3
4 files changed
+31 -24

No files matched your search

+11 -8
View File
@@ -1,9 +1,4 @@
<script lang="ts">
import type {
CommentReplyView,
PersonMentionView,
PrivateMessageView,
} from 'lemmy-js-client'
import InboxItem from './InboxItem.svelte'
import Button from '$lib/components/input/Button.svelte'
import { Check, Icon } from 'svelte-hero-icons'
@@ -11,10 +6,9 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { isRead } from '$lib/lemmy/inbox.js'
import Pageination from '$lib/components/ui/Pageination.svelte'
export let data: {
data: PersonMentionView[] | CommentReplyView[] | PrivateMessageView[]
}
export let data
let markingAsRead = false
@@ -67,5 +61,14 @@
{#each data.data as item}
<InboxItem {item} read={isRead(item)} />
{/each}
<Pageination
page={data.page}
on:change={(p) => {
$page.url.searchParams.set('page', p.detail.toString())
goto($page.url.toString(), {
invalidateAll: true,
})
}}
/>
{/if}
</div>
+5 -3
View File
@@ -2,15 +2,17 @@ import { authData, getClient } from '$lib/lemmy.js'
import { getInboxItemPublished } from '$lib/lemmy/inbox.js'
import { get } from 'svelte/store'
export async function load() {
export async function load({ url }) {
const auth = get(authData)
if (!auth) return
const client = getClient()
const page = Number(url.searchParams.get('page')) || 1
const params = {
limit: 50,
page: 1,
page: page,
auth: auth.token,
}
@@ -36,5 +38,5 @@ export async function load() {
Date.parse(getInboxItemPublished(a))
)
return { data: data }
return { page: page, data: data }
}