feat: Add default sorts
This commit is contained in:
1 parent
75a7e87110
commit
123336871d
6 files changed
+49
-8
No files matched your search
@@ -9,6 +9,7 @@
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { Color } from '$lib/ui/colors'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
|
||||
export let data
|
||||
</script>
|
||||
@@ -50,7 +51,8 @@
|
||||
<MultiSelect
|
||||
options={['Active', 'Hot', 'TopAll', 'New']}
|
||||
optionNames={['Active', 'Hot', 'Top', 'New']}
|
||||
selected={$page.url.searchParams.get('sort') ?? 'Active'}
|
||||
selected={$page.url.searchParams.get('sort') ??
|
||||
$userSettings.defaultSort.sort}
|
||||
on:select={(e) => {
|
||||
const url = $page.url
|
||||
url.searchParams.set('sort', e.detail)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { ListingType, SortType } from 'lemmy-js-client'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
@@ -6,7 +7,8 @@ export async function load(req: any) {
|
||||
const page = Number(req.url.searchParams.get('page') || 1) || 1
|
||||
|
||||
const sort: SortType =
|
||||
(req.url.searchParams.get('sort') as SortType) || 'Active'
|
||||
(req.url.searchParams.get('sort') as SortType) ||
|
||||
get(userSettings).defaultSort.sort
|
||||
|
||||
return {
|
||||
posts: getClient().getPosts({
|
||||
@@ -18,7 +20,7 @@ export async function load(req: any) {
|
||||
}),
|
||||
community: getClient().getCommunity({
|
||||
name: req.params.name,
|
||||
auth: get(authData)?.token
|
||||
auth: get(authData)?.token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user