diff --git a/src/routes/inbox/+page.svelte b/src/routes/inbox/+page.svelte index f89d071a..24d180f2 100644 --- a/src/routes/inbox/+page.svelte +++ b/src/routes/inbox/+page.svelte @@ -7,6 +7,7 @@ import { page } from '$app/stores' import { isRead } from '$lib/lemmy/inbox.js' import Pageination from '$lib/components/ui/Pageination.svelte' + import MultiSelect from '$lib/components/input/MultiSelect.svelte' export let data @@ -52,6 +53,19 @@ Mark all as read +
+ { + $page.url.searchParams.delete('page') + $page.url.searchParams.set('type', e.detail ?? 'all') + goto($page.url.toString(), { + invalidateAll: true, + }) + }} +/>
{#if !data.data || (data.data?.length ?? 0) == 0}

diff --git a/src/routes/inbox/+page.ts b/src/routes/inbox/+page.ts index f1478013..6de04781 100644 --- a/src/routes/inbox/+page.ts +++ b/src/routes/inbox/+page.ts @@ -2,12 +2,15 @@ import { authData, getClient } from '$lib/lemmy.js' import { getInboxItemPublished } from '$lib/lemmy/inbox.js' import { get } from 'svelte/store' +type InboxFeedType = 'replies' | 'mentions' | 'messages' | 'all' + export async function load({ url }) { const auth = get(authData) if (!auth) return + const type: InboxFeedType = + (url.searchParams.get('type') as InboxFeedType) || 'all' const client = getClient() - const page = Number(url.searchParams.get('page')) || 1 const params = { @@ -17,15 +20,25 @@ export async function load({ url }) { } const [replies, mentions, privateMessages] = await Promise.all([ - client.getReplies({ - ...params, - sort: 'New', - }), - client.getPersonMentions({ - ...params, - sort: 'New', - }), - client.getPrivateMessages(params), + type == 'all' || type == 'replies' + ? client.getReplies({ + ...params, + sort: 'New', + }) + : { replies: [] }, + type == 'all' || type == 'mentions' + ? client.getPersonMentions({ + ...params, + sort: 'New', + }) + : { + mentions: [], + }, + type == 'all' || type == 'messages' + ? client.getPrivateMessages({ ...params }) + : { + private_messages: [], + }, ]) const data = [ @@ -38,5 +51,5 @@ export async function load({ url }) { Date.parse(getInboxItemPublished(a)) ) - return { page: page, data: data } + return { type: type, page: page, data: data } } diff --git a/src/routes/inbox/InboxItem.svelte b/src/routes/inbox/InboxItem.svelte index 33d828df..fad496b8 100644 --- a/src/routes/inbox/InboxItem.svelte +++ b/src/routes/inbox/InboxItem.svelte @@ -70,7 +70,7 @@

{item.creator.display_name ?? item.creator.name}