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">
|
<script lang="ts">
|
||||||
import InboxItem from './InboxItem.svelte'
|
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 { getClient } from '$lib/lemmy.js'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
@@ -11,7 +17,7 @@
|
|||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
import { searchParam } from '$lib/util.js'
|
import { searchParam } from '$lib/util.js'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button, Select } from 'mono-svelte'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
@@ -59,30 +65,36 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-4" />
|
<div class="mt-4" />
|
||||||
<div class="flex flex-row gap-4 flex-wrap">
|
<div class="flex flex-row gap-4 flex-wrap">
|
||||||
<MultiSelect
|
<Select
|
||||||
selected={data.unreadOnly}
|
bind:value={data.unreadOnly}
|
||||||
options={[false, true]}
|
on:change={() =>
|
||||||
optionNames={['All', 'Unread']}
|
searchParam(
|
||||||
on:select={(e) => {
|
$page.url,
|
||||||
$page.url.searchParams.delete('page')
|
'unreadOnly',
|
||||||
$page.url.searchParams.set('unreadOnly', (e.detail ?? false).toString())
|
data.unreadOnly?.toString() ?? 'false',
|
||||||
goto($page.url.toString(), {
|
'page'
|
||||||
invalidateAll: true,
|
)}
|
||||||
})
|
>
|
||||||
}}
|
<span slot="label" class="flex items-center gap-1">
|
||||||
/>
|
<Icon src={Funnel} size="15" mini />
|
||||||
<MultiSelect
|
Filter
|
||||||
selected={data.type}
|
</span>
|
||||||
options={['all', 'mentions', 'replies', 'messages']}
|
<option value="false">All</option>
|
||||||
optionNames={['All', 'Mentions', 'Replies', 'Messages']}
|
<option value="true">Unread</option>
|
||||||
on:select={(e) => {
|
</Select>
|
||||||
$page.url.searchParams.delete('page')
|
<Select
|
||||||
$page.url.searchParams.set('type', e.detail ?? 'all')
|
bind:value={data.type}
|
||||||
goto($page.url.toString(), {
|
on:change={() => searchParam($page.url, 'type', data.type ?? 'all', 'page')}
|
||||||
invalidateAll: true,
|
>
|
||||||
})
|
<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>
|
||||||
<div class="flex flex-col gap-4 list-none my-4 flex-1">
|
<div class="flex flex-col gap-4 list-none my-4 flex-1">
|
||||||
{#if !data.data || (data.data?.length ?? 0) == 0}
|
{#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'
|
(url.searchParams.get('type') as InboxFeedType) || 'all'
|
||||||
const client = getClient(undefined, fetch)
|
const client = getClient(undefined, fetch)
|
||||||
const page = Number(url.searchParams.get('page')) || 1
|
const page = Number(url.searchParams.get('page')) || 1
|
||||||
const unreadOnly: boolean =
|
const unreadOnly: string = url.searchParams.get('unreadOnly') || 'true'
|
||||||
(url.searchParams.get('unreadOnly') || 'true') == 'true'
|
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
limit: 50,
|
limit: 20,
|
||||||
page: page,
|
page: page,
|
||||||
auth: auth.jwt,
|
auth: auth.jwt,
|
||||||
unread_only: unreadOnly,
|
unread_only: unreadOnly == 'true',
|
||||||
}
|
}
|
||||||
|
|
||||||
const [replies, mentions, privateMessages] = await Promise.all([
|
const [replies, mentions, privateMessages] = await Promise.all([
|
||||||
|
|||||||
Reference in new issue
Block a user