migrate: change settings from a store to a state
This commit is contained in:
1 parent
ffcd9faa96
commit
d597349887
128 files changed
+1010
-1144
No files matched your search
@@ -1,10 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import { page } from '$app/stores'
|
||||
import { profile } from '$lib/auth'
|
||||
import { userSettings } from '$lib/settings'
|
||||
import { searchParam } from '$lib/util'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { searchParam } from '$lib/util.svelte'
|
||||
import { Select } from 'mono-svelte'
|
||||
import {
|
||||
GlobeAmericas,
|
||||
@@ -25,32 +22,19 @@
|
||||
}
|
||||
|
||||
let {
|
||||
selected,
|
||||
selected = $bindable(),
|
||||
navigate = true,
|
||||
changeDefault = false,
|
||||
showLabel = true,
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
let feed: string = $state(selected)
|
||||
run(() => {
|
||||
feed = selected
|
||||
})
|
||||
run(() => {
|
||||
changeDefault
|
||||
? ($userSettings.defaultSort.feed = selected as
|
||||
| 'All'
|
||||
| 'Subscribed'
|
||||
| 'Local')
|
||||
: undefined
|
||||
})
|
||||
</script>
|
||||
|
||||
<Select
|
||||
{...rest}
|
||||
bind:value={feed}
|
||||
bind:value={selected}
|
||||
on:change={() => {
|
||||
if (navigate) searchParam($page.url, 'type', feed, 'page', 'cursor')
|
||||
if (navigate) searchParam($page.url, 'type', selected, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
{#snippet customLabel()}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import { page } from '$app/stores'
|
||||
import { userSettings } from '$lib/settings'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import { searchParam } from '$lib/util.svelte.js'
|
||||
import type { SortType } from 'lemmy-js-client'
|
||||
import { Select } from 'mono-svelte'
|
||||
import {
|
||||
@@ -45,17 +45,6 @@
|
||||
|
||||
let sort: string = $state(selected?.startsWith('Top') ? 'TopAll' : selected)
|
||||
const setSelected = () => (selected = sort)
|
||||
|
||||
run(() => {
|
||||
if (selected) {
|
||||
sort = selected?.startsWith('Top') ? 'TopAll' : selected
|
||||
}
|
||||
})
|
||||
run(() => {
|
||||
changeDefault
|
||||
? ($userSettings.defaultSort.sort = selected as SortType)
|
||||
: undefined
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="flex flex-row {clazz}">
|
||||
@@ -68,7 +57,7 @@
|
||||
if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
{#snippet label()}
|
||||
{#snippet customLabel()}
|
||||
<span class="flex items-center gap-1">
|
||||
<Icon src={ChartBar} size="13" micro />
|
||||
{$t('filter.sort.label')}
|
||||
@@ -167,7 +156,7 @@
|
||||
searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
{#snippet label()}
|
||||
{#snippet customLabel()}
|
||||
<span class="flex items-center gap-1">
|
||||
<Icon src={Clock} size="15" micro />
|
||||
{$t('filter.sort.top.time.label')}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { t } from '$lib/translations'
|
||||
import { Select } from 'mono-svelte'
|
||||
import {
|
||||
@@ -21,7 +21,7 @@
|
||||
let { showLabel = true, ...rest }: Props = $props()
|
||||
</script>
|
||||
|
||||
<Select {...rest} bind:value={$userSettings.view}>
|
||||
<Select {...rest} bind:value={settings.view}>
|
||||
{#snippet customLabel()}
|
||||
{#if showLabel}
|
||||
<span class="flex items-center gap-1">
|
||||
|
||||
Reference in new issue
Block a user