feat: add sort to settings

This commit is contained in:
Xyphyn committed 2023-08-04 14:40:39 -07:00
1 parent dc1aba6c17
commit 2c4826e745
3 files changed
+9 -8

No files matched your search

+5 -2
View File
@@ -4,6 +4,7 @@
import MultiSelect from '../input/MultiSelect.svelte' import MultiSelect from '../input/MultiSelect.svelte'
export let selected: string export let selected: string
export let navigate: boolean = true
</script> </script>
<MultiSelect <MultiSelect
@@ -31,7 +32,9 @@
'Most Comments', 'Most Comments',
'New Comments', 'New Comments',
]} ]}
{selected} bind:selected
on:select={(e) => searchParam($page.url, 'sort', e.detail, 'page')} on:select={(e) => {
if (navigate) searchParam($page.url, 'sort', e.detail, 'page')
}}
class="w-full md:max-w-[20rem]" class="w-full md:max-w-[20rem]"
/> />
+2 -1
View File
@@ -1,3 +1,4 @@
import type { SortType } from 'lemmy-js-client'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
interface Settings { interface Settings {
@@ -13,7 +14,7 @@ interface Settings {
} }
showCompactPosts: boolean showCompactPosts: boolean
defaultSort: { defaultSort: {
sort: 'Hot' | 'TopAll' | 'Active' | 'New' sort: SortType
feed: 'All' | 'Subscribed' | 'Local' feed: 'All' | 'Subscribed' | 'Local'
} }
fullWidthLayout: boolean fullWidthLayout: boolean
+2 -5
View File
@@ -13,6 +13,7 @@
import { toast } from '$lib/components/ui/toasts/toasts.js' import { toast } from '$lib/components/ui/toasts/toasts.js'
import Setting from './Setting.svelte' import Setting from './Setting.svelte'
import MultiSelect from '$lib/components/input/MultiSelect.svelte' import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import Sort from '$lib/components/lemmy/Sort.svelte'
let data = { let data = {
loading: false, loading: false,
@@ -39,11 +40,7 @@
</div> </div>
<div> <div>
<span class="block my-1 font-bold">Sort</span> <span class="block my-1 font-bold">Sort</span>
<MultiSelect <Sort bind:selected={$userSettings.defaultSort.sort} navigate={false} />
options={['Active', 'Hot', 'TopAll', 'New']}
optionNames={['Active', 'Hot', 'Top', 'New']}
bind:selected={$userSettings.defaultSort.sort}
/>
</div> </div>
</div> </div>
</Setting> </Setting>