feat: add password changing
This commit is contained in:
1 parent
505175277c
commit
76f22dab5c
12 files changed
+138
-54
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { getItemPublished } from '$lib/lemmy/item.js'
|
||||
import type { SortType } from 'lemmy-js-client'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export async function load({ url, fetch, parent }) {
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
const type: 'comments' | 'posts' | 'all' =
|
||||
(url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all'
|
||||
const sort: SortType = (url.searchParams.get('sort') as SortType) || 'New'
|
||||
|
||||
const { my_user } = await parent()
|
||||
|
||||
const user = await getClient(undefined, fetch).getPersonDetails({
|
||||
limit: 20,
|
||||
page: page,
|
||||
username: my_user?.local_user_view.person.name,
|
||||
sort: sort,
|
||||
auth: get(profile)?.jwt,
|
||||
})
|
||||
|
||||
const items = [...user.posts, ...user.comments]
|
||||
|
||||
if (sort == 'TopAll') {
|
||||
items.sort(
|
||||
(a, b) =>
|
||||
b.counts.upvotes -
|
||||
b.counts.downvotes -
|
||||
(a.counts.upvotes - a.counts.downvotes)
|
||||
)
|
||||
} else if (sort == 'New') {
|
||||
items.sort(
|
||||
(a, b) =>
|
||||
Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a))
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
type: type,
|
||||
page: page,
|
||||
sort: sort,
|
||||
user: {
|
||||
submissions: items,
|
||||
moderates: user.moderates,
|
||||
person_view: user.person_view,
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user