misc: use select menu in inbox
This commit is contained in:
1 parent
b6792374b8
commit
df4ed6b9c3
2 files changed
+41
-30
No files matched your search
@@ -1,6 +1,12 @@
|
||||
<script lang="ts">
|
||||
import InboxItem from './InboxItem.svelte'
|
||||
import { Check, Icon, Inbox } from 'svelte-hero-icons'
|
||||
import {
|
||||
Bars3BottomRight,
|
||||
Check,
|
||||
Funnel,
|
||||
Icon,
|
||||
Inbox,
|
||||
} from 'svelte-hero-icons'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
@@ -11,7 +17,7 @@
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Button, Select } from 'mono-svelte'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -59,30 +65,36 @@
|
||||
</div>
|
||||
<div class="mt-4" />
|
||||
<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,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<Select
|
||||
bind:value={data.unreadOnly}
|
||||
on:change={() =>
|
||||
searchParam(
|
||||
$page.url,
|
||||
'unreadOnly',
|
||||
data.unreadOnly?.toString() ?? 'false',
|
||||
'page'
|
||||
)}
|
||||
>
|
||||
<span slot="label" class="flex items-center gap-1">
|
||||
<Icon src={Funnel} size="15" mini />
|
||||
Filter
|
||||
</span>
|
||||
<option value="false">All</option>
|
||||
<option value="true">Unread</option>
|
||||
</Select>
|
||||
<Select
|
||||
bind:value={data.type}
|
||||
on:change={() => searchParam($page.url, 'type', data.type ?? 'all', 'page')}
|
||||
>
|
||||
<span slot="label" class="flex items-center gap-1">
|
||||
<Icon src={Bars3BottomRight} size="15" mini />
|
||||
Type
|
||||
</span>
|
||||
<option value="all">All</option>
|
||||
<option value="mentions">Mentions</option>
|
||||
<option value="replies">Replies</option>
|
||||
<option value="messages">Messages</option>
|
||||
</Select>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4 list-none my-4 flex-1">
|
||||
{#if !data.data || (data.data?.length ?? 0) == 0}
|
||||
|
||||
@@ -13,14 +13,13 @@ export async function load({ url, fetch }) {
|
||||
(url.searchParams.get('type') as InboxFeedType) || 'all'
|
||||
const client = getClient(undefined, fetch)
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
const unreadOnly: boolean =
|
||||
(url.searchParams.get('unreadOnly') || 'true') == 'true'
|
||||
const unreadOnly: string = url.searchParams.get('unreadOnly') || 'true'
|
||||
|
||||
const params = {
|
||||
limit: 50,
|
||||
limit: 20,
|
||||
page: page,
|
||||
auth: auth.jwt,
|
||||
unread_only: unreadOnly,
|
||||
unread_only: unreadOnly == 'true',
|
||||
}
|
||||
|
||||
const [replies, mentions, privateMessages] = await Promise.all([
|
||||
|
||||
Reference in new issue
Block a user