feat: make sort changes the default
This commit is contained in:
1 parent
2bce912604
commit
4dab003ae2
3 files changed
+14
-4
No files matched your search
@@ -1,17 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import { userSettings } from '$lib/settings'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import { feature } from '$lib/version.js'
|
||||
import type { SortType } from 'lemmy-js-client'
|
||||
import { Select } from 'mono-svelte'
|
||||
import { ChartBar, Clock, Icon } from 'svelte-hero-icons'
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
export let selected: string
|
||||
export let navigate: boolean = true
|
||||
export let changeDefault: boolean = false
|
||||
|
||||
let sort: string = selected.startsWith('Top') ? 'TopAll' : selected
|
||||
const setSelected = () => (selected = sort)
|
||||
$: changeDefault
|
||||
? ($userSettings.defaultSort.sort = selected as SortType)
|
||||
: undefined
|
||||
</script>
|
||||
|
||||
<div class="flex flex-row gap-2 {$$props.class}">
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import { amModOfAny } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import { feature } from '$lib/version.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -49,8 +50,11 @@
|
||||
<div class="flex flex-row gap-2 max-w-full justify-between w-full flex-wrap">
|
||||
<Select
|
||||
bind:value={data.listingType}
|
||||
on:change={() =>
|
||||
searchParam($page.url, 'type', data.listingType, 'page', 'cursor')}
|
||||
on:change={() => {
|
||||
// @ts-ignore
|
||||
$userSettings.defaultSort.feed = data.listingType
|
||||
searchParam($page.url, 'type', data.listingType, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
<span slot="label" class="flex items-center gap-1">
|
||||
<Icon src={GlobeAmericas} size="16" mini />
|
||||
@@ -69,7 +73,7 @@
|
||||
{/if}
|
||||
</Select>
|
||||
<div class="flex gap-2 flex-wrap">
|
||||
<Sort selected={data.sort} />
|
||||
<Sort changeDefault selected={data.sort} />
|
||||
<div class="max-[420px]:hidden">
|
||||
<ViewSelect />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user