From 81270b72d316ba12e31571dd71e857903b15fc5a Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Thu, 27 Jul 2023 12:30:09 -0700 Subject: [PATCH] feat: Add pagination to inbox page --- src/lib/lemmy/item.ts | 17 ++++++++++++++--- src/routes/inbox/+page.svelte | 19 +++++++++++-------- src/routes/inbox/+page.ts | 8 +++++--- src/routes/search/+page.svelte | 11 +---------- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/lib/lemmy/item.ts b/src/lib/lemmy/item.ts index a2e8e43e..ad914bed 100644 --- a/src/lib/lemmy/item.ts +++ b/src/lib/lemmy/item.ts @@ -5,9 +5,9 @@ import type { PostView, } from 'lemmy-js-client' -export function getItemPublished( - item: PostView | CommentView | PersonView | CommunityView -) { +type Result = PostView | CommentView | PersonView | CommunityView + +export function getItemPublished(item: Result) { if ('comment' in item) { return item.comment.published } else if ('post' in item) { @@ -24,3 +24,14 @@ export function getItemPublished( return '' } + +export const isPost = (item: Result): item is PostView => + 'post' in item && !('comment' in item) + +export const isComment = (item: Result): item is CommentView => + 'comment' in item + +export const isCommunity = (item: Result): item is CommunityView => + 'community' in item + +export const isUser = (item: Result): item is PersonView => 'person' in item diff --git a/src/routes/inbox/+page.svelte b/src/routes/inbox/+page.svelte index fccc33be..f89d071a 100644 --- a/src/routes/inbox/+page.svelte +++ b/src/routes/inbox/+page.svelte @@ -1,9 +1,4 @@