feat: add default comment sorts, close #93

This commit is contained in:
Xyphyn committed 2023-08-10 17:01:25 -07:00
1 parent c5afc07b41
commit f9becd1bd0
7 files changed
+27 -13

No files matched your search

@@ -36,7 +36,7 @@
})
let commentsPage = 1
let commentSort: CommentSortType = 'Hot'
let commentSort: CommentSortType = data.commentSort
let loading = false
let moreComments = true
@@ -46,7 +46,6 @@
data.streamed.comments = getClient().getComments({
auth: $profile?.jwt,
max_depth: 3,
page: commentsPage,
limit: 25,
type_: 'All',
@@ -1,5 +1,6 @@
import { profile } from '$lib/auth.js'
import { getClient } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings.js'
import { error } from '@sveltejs/kit'
import { get } from 'svelte/store'
@@ -26,9 +27,12 @@ export async function load({ params, url, fetch }) {
max_depth = 10
}
const sort = get(userSettings)?.defaultSort?.comments ?? 'Hot'
return {
singleThread: parentId != undefined,
post: post,
commentSort: sort,
streamed: {
comments: getClient(params.instance.toLowerCase(), fetch).getComments({
post_id: Number(params.id),
@@ -37,7 +41,7 @@ export async function load({ params, url, fetch }) {
page: 1,
max_depth: max_depth,
saved_only: false,
sort: 'Hot',
sort: sort,
auth: get(profile)?.jwt,
parent_id: parentId,
}),