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,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { notifications, profile } from '$lib/auth.js'
|
||||
import { notifications, profile } from '$lib/auth.svelte.js'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
import {
|
||||
amModOfAny,
|
||||
@@ -36,7 +36,7 @@
|
||||
import { t } from '$lib/translations'
|
||||
import CommandsWrapper from './commands/CommandsWrapper.svelte'
|
||||
import { optimizeImageURL } from '$lib/components/lemmy/post/helpers'
|
||||
import { userSettings } from '$lib/settings'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { dockProps } from '../layout/Shell.svelte'
|
||||
|
||||
let promptOpen: boolean = $state(false)
|
||||
@@ -67,7 +67,7 @@
|
||||
class="ml-2 logo"
|
||||
adaptive={false}
|
||||
>
|
||||
{#snippet icon()}
|
||||
{#snippet customIcon()}
|
||||
{#if LINKED_INSTANCE_URL}
|
||||
{#if $site}
|
||||
<Avatar
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { stopPropagation } from 'svelte/legacy'
|
||||
|
||||
import { notifications, profile } from '$lib/auth'
|
||||
import { notifications, profile } from '$lib/auth.svelte'
|
||||
|
||||
import {
|
||||
Badge,
|
||||
@@ -34,7 +34,7 @@
|
||||
UserGroup,
|
||||
} from 'svelte-hero-icons'
|
||||
import { colorScheme } from '$lib/ui/colors'
|
||||
import { userSettings } from '$lib/settings'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { site } from '$lib/lemmy'
|
||||
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
@@ -185,7 +185,7 @@
|
||||
{/snippet}
|
||||
{$t('nav.menu.theme')}
|
||||
</MenuButton>
|
||||
{#if $userSettings.debugInfo}
|
||||
{#if settings.debugInfo}
|
||||
<MenuButton link href="/util">
|
||||
{#snippet prefix()}
|
||||
<Icon src={BugAnt} mini width={16} />
|
||||
|
||||
@@ -7,16 +7,15 @@
|
||||
type IconSource,
|
||||
} from 'svelte-hero-icons'
|
||||
import Avatar from '../../Avatar.svelte'
|
||||
import type { Action } from './actions'
|
||||
import type { Action } from './actions.svelte'
|
||||
|
||||
interface Props {
|
||||
action: Action;
|
||||
class?: string;
|
||||
children?: import('svelte').Snippet;
|
||||
action: Action
|
||||
class?: string
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let { action, class: clazz = '', children }: Props = $props();
|
||||
|
||||
let { action, class: clazz = '', children }: Props = $props()
|
||||
</script>
|
||||
|
||||
<Button
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy';
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import { resumables } from '$lib/lemmy/item'
|
||||
import { TextInput } from 'mono-svelte'
|
||||
@@ -9,19 +9,17 @@
|
||||
import CommandItem from './CommandItem.svelte'
|
||||
import { browser } from '$app/environment'
|
||||
import { afterNavigate, goto } from '$app/navigation'
|
||||
import { profile, profileData } from '$lib/auth'
|
||||
import { getGroups, type Action, type Group } from './actions'
|
||||
import { profile, profileData } from '$lib/auth.svelte'
|
||||
import { getGroups, type Action, type Group } from './actions.svelte'
|
||||
import { themeData } from '$lib/ui/colors'
|
||||
import { page } from '$app/stores'
|
||||
|
||||
|
||||
interface Props {
|
||||
open?: boolean;
|
||||
groups?: Group[];
|
||||
open?: boolean
|
||||
groups?: Group[]
|
||||
}
|
||||
|
||||
let { open = $bindable(false), groups = $bindable([]) }: Props = $props();
|
||||
|
||||
let { open = $bindable(false), groups = $bindable([]) }: Props = $props()
|
||||
|
||||
let search = $state('')
|
||||
let container: HTMLElement = $state()
|
||||
@@ -87,7 +85,7 @@
|
||||
score: Math.max(
|
||||
fuzzySearch(action.name, term),
|
||||
fuzzySearch(group.name, term),
|
||||
action.detail ? fuzzySearch(action.detail, term) : -1
|
||||
action.detail ? fuzzySearch(action.detail, term) : -1,
|
||||
),
|
||||
}))
|
||||
.filter((action) => action.score > 0)
|
||||
@@ -98,7 +96,7 @@
|
||||
actions: scoredActions,
|
||||
score: Math.max(
|
||||
fuzzySearch(group.name, term),
|
||||
...scoredActions.map((a) => a.score)
|
||||
...scoredActions.map((a) => a.score),
|
||||
),
|
||||
}
|
||||
})
|
||||
@@ -130,10 +128,9 @@
|
||||
updateFilteredGroups()
|
||||
}
|
||||
|
||||
|
||||
function flattenActions(
|
||||
actions: Action[],
|
||||
subaction: boolean = true
|
||||
subaction: boolean = true,
|
||||
): Action[] {
|
||||
return actions.flatMap((action) => [
|
||||
action,
|
||||
@@ -230,20 +227,22 @@
|
||||
})
|
||||
run(() => {
|
||||
if (open) search = ''
|
||||
});
|
||||
})
|
||||
run(() => {
|
||||
groups = getGroups(
|
||||
$resumables,
|
||||
$profile,
|
||||
$profileData.profiles,
|
||||
$themeData,
|
||||
$page.data.contextual?.actions
|
||||
$page.data.contextual?.actions,
|
||||
)
|
||||
});
|
||||
let flattenedActions = $derived(filteredGroups.flatMap((group) => group.actions))
|
||||
})
|
||||
let flattenedActions = $derived(
|
||||
filteredGroups.flatMap((group) => group.actions),
|
||||
)
|
||||
run(() => {
|
||||
debouncedSearch(search)
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
import { CommandLine, Icon } from 'svelte-hero-icons'
|
||||
|
||||
interface Props {
|
||||
open?: boolean;
|
||||
open?: boolean
|
||||
}
|
||||
|
||||
let { open = $bindable(false) }: Props = $props();
|
||||
let { open = $bindable(false) }: Props = $props()
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
{#if open}
|
||||
<Modal bind:open>
|
||||
{#snippet title()}
|
||||
<span class="flex items-center gap-1">
|
||||
{#snippet customTitle()}
|
||||
<span class="flex items-center gap-1">
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
@@ -40,7 +40,7 @@
|
||||
</svg>
|
||||
{$t('nav.commands.prompt')}
|
||||
</span>
|
||||
{/snippet}
|
||||
{/snippet}
|
||||
{#await import('./Commands.svelte')}
|
||||
<div class="h-96 flex flex-col gap-2 items-center justify-center">
|
||||
<Spinner width={32} />
|
||||
|
||||
+6
-26
@@ -1,15 +1,15 @@
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import { setUserID, type Profile } from '$lib/auth'
|
||||
import { setUserID, type Profile } from '$lib/auth.svelte'
|
||||
import {
|
||||
amModOfAny,
|
||||
isAdmin,
|
||||
} from '$lib/components/lemmy/moderation/moderation'
|
||||
import { resumables, type ResumableItem } from '$lib/lemmy/item'
|
||||
import { userSettings } from '$lib/settings.svelte'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import { colorScheme, theme, themeData, type ThemeData } from '$lib/ui/colors'
|
||||
import { fullCommunityName } from '$lib/util'
|
||||
import { fullCommunityName } from '$lib/util.svelte'
|
||||
import {
|
||||
ArrowRightOnRectangle,
|
||||
Bookmark,
|
||||
@@ -339,10 +339,7 @@ export function getGroups(
|
||||
}),
|
||||
icon: ViewColumns,
|
||||
handle: () =>
|
||||
userSettings.update((s) => ({
|
||||
...s,
|
||||
view: 'compact',
|
||||
})),
|
||||
settings.view = 'compact'
|
||||
},
|
||||
{
|
||||
name: t.get('nav.commands.setViewTo', {
|
||||
@@ -350,10 +347,7 @@ export function getGroups(
|
||||
}),
|
||||
icon: ViewColumns,
|
||||
handle: () =>
|
||||
userSettings.update((s) => ({
|
||||
...s,
|
||||
view: 'cozy',
|
||||
})),
|
||||
settings.view = 'cozy'
|
||||
},
|
||||
{
|
||||
name: t.get('nav.commands.setViewTo', {
|
||||
@@ -361,21 +355,7 @@ export function getGroups(
|
||||
}),
|
||||
icon: ViewColumns,
|
||||
handle: () =>
|
||||
userSettings.update((s) => ({
|
||||
...s,
|
||||
view: 'list',
|
||||
})),
|
||||
},
|
||||
{
|
||||
name: t.get('nav.commands.setViewTo', {
|
||||
default: t.get('filter.view.legacy'),
|
||||
}),
|
||||
icon: ViewColumns,
|
||||
handle: () =>
|
||||
userSettings.update((s) => ({
|
||||
...s,
|
||||
view: 'card',
|
||||
})),
|
||||
settings.view = 'list'
|
||||
},
|
||||
],
|
||||
},
|
||||
Reference in new issue
Block a user