feat: add unread filters to inbox and reports
This commit is contained in:
1 parent
d65c62d2d9
commit
1c9661546c
4 files changed
+81
-20
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import InboxItem from './InboxItem.svelte'
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { Check, Icon } from 'svelte-hero-icons'
|
||||
import { Check, EnvelopeOpen, Icon } from 'svelte-hero-icons'
|
||||
import { authData, getClient, user } from '$lib/lemmy.js'
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
@@ -54,23 +54,43 @@
|
||||
</Button>
|
||||
</div>
|
||||
<div class="mt-4" />
|
||||
<MultiSelect
|
||||
selected={data.type}
|
||||
options={['all', 'mentions', 'replies', 'messages']}
|
||||
optionNames={['All', 'Mentions', 'Replies', 'Messages']}
|
||||
on:select={(e) => {
|
||||
$page.url.searchParams.delete('page')
|
||||
$page.url.searchParams.set('type', e.detail ?? 'all')
|
||||
goto($page.url.toString(), {
|
||||
invalidateAll: true,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<div class="flex flex-row gap-4 flex-wrap">
|
||||
<MultiSelect
|
||||
selected={data.unreadOnly}
|
||||
options={[false, true]}
|
||||
optionNames={['All', 'Unread']}
|
||||
on:select={(e) => {
|
||||
$page.url.searchParams.delete('page')
|
||||
$page.url.searchParams.set('unreadOnly', (e.detail ?? false).toString())
|
||||
goto($page.url.toString(), {
|
||||
invalidateAll: true,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<MultiSelect
|
||||
selected={data.type}
|
||||
options={['all', 'mentions', 'replies', 'messages']}
|
||||
optionNames={['All', 'Mentions', 'Replies', 'Messages']}
|
||||
on:select={(e) => {
|
||||
$page.url.searchParams.delete('page')
|
||||
$page.url.searchParams.set('type', e.detail ?? 'all')
|
||||
goto($page.url.toString(), {
|
||||
invalidateAll: true,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4 list-none my-4">
|
||||
{#if !data.data || (data.data?.length ?? 0) == 0}
|
||||
<p class="text-center opacity-60 text-lg mx-4">
|
||||
Wow, it's quite empty in here.
|
||||
</p>
|
||||
<div
|
||||
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center py-8 gap-2"
|
||||
>
|
||||
<Icon src={EnvelopeOpen} size="48" />
|
||||
<div>
|
||||
<h1 class="font-bold text-3xl">Inbox empty</h1>
|
||||
<p class="mt-2 text-center">You're all caught up!</p>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
{#each data.data as item}
|
||||
<InboxItem {item} read={isRead(item)} />
|
||||
|
||||
@@ -12,11 +12,14 @@ export async function load({ url }) {
|
||||
(url.searchParams.get('type') as InboxFeedType) || 'all'
|
||||
const client = getClient()
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
const unreadOnly: boolean =
|
||||
(url.searchParams.get('unreadOnly') || 'true') == 'true'
|
||||
|
||||
const params = {
|
||||
limit: 50,
|
||||
page: page,
|
||||
auth: auth.token,
|
||||
unread_only: unreadOnly,
|
||||
}
|
||||
|
||||
const [replies, mentions, privateMessages] = await Promise.all([
|
||||
@@ -51,5 +54,5 @@ export async function load({ url }) {
|
||||
Date.parse(getInboxItemPublished(a))
|
||||
)
|
||||
|
||||
return { type: type, page: page, data: data }
|
||||
return { unreadOnly: unreadOnly, type: type, page: page, data: data }
|
||||
}
|
||||
Reference in new issue
Block a user