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
@@ -2,11 +2,19 @@ import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { getItemPublished } from '$lib/lemmy/item.js'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
type ReportListType = 'unread' | 'all'
|
||||
type ReportFilter = 'all' | 'posts' | 'comments' | 'messages'
|
||||
|
||||
export async function load({ url }) {
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
const type: ReportListType =
|
||||
(url.searchParams.get('type') as ReportListType) || 'unread'
|
||||
const filter: ReportFilter =
|
||||
(url.searchParams.get('filter') as ReportFilter) || 'all'
|
||||
|
||||
const jwt = get(authData)?.token
|
||||
|
||||
if (!jwt) return { page: page }
|
||||
if (!jwt) return { type: type, page: page }
|
||||
|
||||
// can they like
|
||||
// make a sane, consistent, and simple API for once
|
||||
@@ -15,13 +23,13 @@ export async function load({ url }) {
|
||||
// the interfaces don't even extend each other
|
||||
// meaning I have to make a separate function to get dates
|
||||
// for EACH FREAKING ITEM KAJSHDAWLD auwdi awiody
|
||||
|
||||
const client = getClient()
|
||||
|
||||
const params = {
|
||||
auth: jwt,
|
||||
limit: 20,
|
||||
page: page,
|
||||
unresolved_only: type == 'unread',
|
||||
}
|
||||
|
||||
const [posts, comments, messages] = await Promise.all([
|
||||
@@ -45,6 +53,7 @@ export async function load({ url }) {
|
||||
)
|
||||
|
||||
return {
|
||||
type: type,
|
||||
page: page,
|
||||
items: everything,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user