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 { fly, scale } from 'svelte/transition'
|
||||
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
||||
import { authData } from '$lib/lemmy.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
|
||||
export let data
|
||||
</script>
|
||||
@@ -27,7 +28,8 @@
|
||||
<MultiSelect
|
||||
options={['Subscribed', 'Local', 'All']}
|
||||
disabled={[$authData?.token == undefined]}
|
||||
selected={$page.url.searchParams.get('type') ?? 'Local'}
|
||||
selected={$page.url.searchParams.get('type') ??
|
||||
$userSettings.defaultSort.feed}
|
||||
on:select={(e) => {
|
||||
const url = $page.url
|
||||
url.searchParams.set('type', e.detail)
|
||||
@@ -38,9 +40,10 @@
|
||||
}}
|
||||
/>
|
||||
<MultiSelect
|
||||
options={['Active', 'Hot', 'TopDay', 'New']}
|
||||
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)
|
||||
|
||||
+6
-2
@@ -1,13 +1,17 @@
|
||||
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'
|
||||
|
||||
export async function load({ url }) {
|
||||
const page = Number(url.searchParams.get('page') || 1) || 1
|
||||
|
||||
const sort: SortType = (url.searchParams.get('sort') as SortType) || 'Active'
|
||||
const sort: SortType =
|
||||
(url.searchParams.get('sort') as SortType) ||
|
||||
get(userSettings).defaultSort.sort
|
||||
const listingType: ListingType =
|
||||
(url.searchParams.get('type') as ListingType) || 'Local'
|
||||
(url.searchParams.get('type') as ListingType) ||
|
||||
get(userSettings).defaultSort.feed
|
||||
|
||||
return {
|
||||
posts: getClient().getPosts({
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import Setting from './Setting.svelte'
|
||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||
|
||||
let data = {
|
||||
newInstance: $instance,
|
||||
@@ -70,6 +71,27 @@
|
||||
</div>
|
||||
</div>
|
||||
</Setting>
|
||||
<Setting>
|
||||
<span slot="title">Default sort</span>
|
||||
<span slot="description">The default sort to use for feeds.</span>
|
||||
<div class="flex flex-wrap flex-row gap-4">
|
||||
<div>
|
||||
<span class="block my-1 font-bold">Feed</span>
|
||||
<MultiSelect
|
||||
options={['Subscribed', 'Local', 'All']}
|
||||
bind:selected={$userSettings.defaultSort.feed}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<span class="block my-1 font-bold">Sort</span>
|
||||
<MultiSelect
|
||||
options={['Active', 'Hot', 'TopAll', 'New']}
|
||||
optionNames={['Active', 'Hot', 'Top', 'New']}
|
||||
bind:selected={$userSettings.defaultSort.sort}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Setting>
|
||||
<h2 class="uppercase font-bold opacity-80 text-sm mt-4">UI</h2>
|
||||
<Setting>
|
||||
<span slot="title">Mark read posts</span>
|
||||
|
||||
Reference in new issue
Block a user