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
@@ -9,7 +9,7 @@
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { Check, Icon, Trash, XMark } from 'svelte-hero-icons'
|
||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||
import { flip } from 'svelte/animate'
|
||||
@@ -22,23 +22,22 @@
|
||||
import UserAutocomplete from '$lib/components/lemmy/user/UserAutocomplete.svelte'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
|
||||
|
||||
interface Props {
|
||||
// sveltekit doesn't feel like making types work right now
|
||||
data: PageData & {
|
||||
person_blocks: PersonBlockView[]
|
||||
community_blocks: CommunityBlockView[]
|
||||
};
|
||||
person_blocks: PersonBlockView[]
|
||||
community_blocks: CommunityBlockView[]
|
||||
}
|
||||
}
|
||||
|
||||
let { data = $bindable() }: Props = $props();
|
||||
let { data = $bindable() }: Props = $props()
|
||||
|
||||
async function unblockUser(item: PersonBlockView) {
|
||||
if (!$profile?.jwt) return
|
||||
|
||||
data.person_blocks.splice(
|
||||
data.person_blocks.findIndex((i) => i.target.id == item.target.id),
|
||||
1
|
||||
1,
|
||||
)
|
||||
// hack to get reactivity working
|
||||
data.person_blocks = data.person_blocks
|
||||
@@ -54,9 +53,9 @@
|
||||
|
||||
data.community_blocks.splice(
|
||||
data.community_blocks.findIndex(
|
||||
(i) => i.community.id == item.community.id
|
||||
(i) => i.community.id == item.community.id,
|
||||
),
|
||||
1
|
||||
1,
|
||||
)
|
||||
|
||||
// hack to get reactivity working
|
||||
@@ -74,9 +73,9 @@
|
||||
|
||||
data.my_user.instance_blocks.splice(
|
||||
data.my_user.instance_blocks.findIndex(
|
||||
(i) => i.instance.id == item.instance.id
|
||||
(i) => i.instance.id == item.instance.id,
|
||||
),
|
||||
1
|
||||
1,
|
||||
)
|
||||
data.my_user.instance_blocks = data.my_user.instance_blocks
|
||||
|
||||
@@ -91,9 +90,9 @@
|
||||
{#if data.my_user?.instance_blocks && (data.my_user?.instance_blocks?.length ?? 0) > 0}
|
||||
<div>
|
||||
<SectionTitle>{$t('content.instances')}</SectionTitle>
|
||||
<EditableList on:action={(i) => unblockInstances(i.detail)}>
|
||||
<EditableList on:action={(i) => unblockInstances(i.detail)}>
|
||||
{#snippet children({ action })}
|
||||
{#each data.my_user?.instance_blocks as block (block.instance.id)}
|
||||
{#each data.my_user?.instance_blocks as block (block.instance.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-4"
|
||||
animate:flip={{ duration: 250 }}
|
||||
@@ -106,8 +105,8 @@
|
||||
on:click={() => action(block)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<Entity
|
||||
icon={block.site?.icon}
|
||||
@@ -116,16 +115,16 @@
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
</div>
|
||||
{/if}
|
||||
{#if data.community_blocks?.length > 0}
|
||||
<div>
|
||||
<SectionTitle>{$t('content.communities')}</SectionTitle>
|
||||
<EditableList on:action={(i) => unblockCommunity(i.detail)}>
|
||||
<EditableList on:action={(i) => unblockCommunity(i.detail)}>
|
||||
{#snippet children({ action })}
|
||||
{#each data.community_blocks as block (block.community.id)}
|
||||
{#each data.community_blocks as block (block.community.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-2"
|
||||
animate:flip={{ duration: 250 }}
|
||||
@@ -138,22 +137,22 @@
|
||||
on:click={() => action(block)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<CommunityLink community={block.community} avatar />
|
||||
</div>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
</div>
|
||||
{/if}
|
||||
{#if data.person_blocks?.length > 0}
|
||||
<div>
|
||||
<SectionTitle>{$t('content.users')}</SectionTitle>
|
||||
<EditableList on:action={(i) => unblockUser(i.detail)}>
|
||||
<EditableList on:action={(i) => unblockUser(i.detail)}>
|
||||
{#snippet children({ action })}
|
||||
{#each data.person_blocks as block (block.target.id)}
|
||||
{#each data.person_blocks as block (block.target.id)}
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center py-2"
|
||||
animate:flip={{ duration: 250 }}
|
||||
@@ -166,14 +165,14 @@
|
||||
on:click={() => action(block)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
<Icon src={XMark} mini size="16" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<UserLink user={block.target} avatar badges />
|
||||
</div>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
{/snippet}
|
||||
</EditableList>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
import { preventDefault } from 'svelte/legacy'
|
||||
|
||||
import { deleteProfile, profile, setUser } from '$lib/auth'
|
||||
import { deleteProfile, profile, setUser } from '$lib/auth.svelte'
|
||||
import { client } from '$lib/lemmy'
|
||||
import { instance as currentInstance } from '$lib/instance'
|
||||
import { t } from '$lib/translations'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { profileData, setUserID } from '$lib/auth'
|
||||
import { profileData, setUserID } from '$lib/auth.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { client } from '$lib/lemmy'
|
||||
import { t } from '$lib/translations'
|
||||
@@ -73,7 +73,7 @@
|
||||
profileData.update((pd) => {
|
||||
pd.profiles.splice(
|
||||
pd.profiles.findIndex((p) => pd.profile == p.id),
|
||||
1
|
||||
1,
|
||||
)
|
||||
|
||||
return pd
|
||||
@@ -102,8 +102,8 @@
|
||||
on:action={() => deleteAccount(4)}
|
||||
>
|
||||
{#snippet title()}
|
||||
<span >{$t('form.profile.deleteAccount.label')}</span>
|
||||
{/snippet}
|
||||
<span>{$t('form.profile.deleteAccount.label')}</span>
|
||||
{/snippet}
|
||||
<TextInput
|
||||
label={$t('form.password')}
|
||||
type="password"
|
||||
@@ -112,10 +112,10 @@
|
||||
<Checkbox bind:checked={deletion.deleteContent}>
|
||||
{$t('form.profile.deleteAccount.deleteContent')}
|
||||
{#snippet description()}
|
||||
<span >
|
||||
<span>
|
||||
{$t('form.profile.deleteAccount.warning')}
|
||||
</span>
|
||||
{/snippet}
|
||||
{/snippet}
|
||||
</Checkbox>
|
||||
</Modal>
|
||||
{/if}
|
||||
@@ -135,10 +135,10 @@
|
||||
<Switch bind:checked={deletion.deleteContent}>
|
||||
{$t('form.profile.deleteAccount.deleteContent')}
|
||||
{#snippet description()}
|
||||
<span >
|
||||
<span>
|
||||
{$t('form.profile.deleteAccount.warning')}
|
||||
</span>
|
||||
{/snippet}
|
||||
{/snippet}
|
||||
</Switch>
|
||||
<Button size="lg" color="danger" on:click={() => deleteAccount(3)}>
|
||||
{$t('routes.profile.delete.title')}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
import { preventDefault } from 'svelte/legacy'
|
||||
|
||||
import { profile, profileData, setUserID } from '$lib/auth.js'
|
||||
import { profile, profileData, setUserID } from '$lib/auth.svelte.js'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { ImageInput, Material, removeToast, toast } from 'mono-svelte'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { SaveUserSettings } from 'lemmy-js-client'
|
||||
import { Button, Switch, TextInput } from 'mono-svelte'
|
||||
import { uploadImage } from '$lib/util.js'
|
||||
import { uploadImage } from '$lib/util.svelte.js'
|
||||
import { t } from '$lib/translations.js'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
interface Props {
|
||||
inline?: boolean;
|
||||
data: any;
|
||||
children?: import('svelte').Snippet;
|
||||
inline?: boolean
|
||||
data: any
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let { inline = false, data, children }: Props = $props();
|
||||
let { inline = false, data, children }: Props = $props()
|
||||
|
||||
let formData: Omit<SaveUserSettings, 'auth'> | undefined = $state({
|
||||
...data.my_user?.local_user_view?.local_user,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { client, getClient } from '$lib/lemmy.js'
|
||||
import { getItemPublished } from '$lib/lemmy/item.js'
|
||||
import type { SortType } from 'lemmy-js-client'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/auth'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
||||
import { isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
@@ -10,7 +10,7 @@
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
||||
import { communityLink } from '$lib/lemmy/generic.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { t } from '$lib/translations'
|
||||
import { Spinner, Button, Menu, MenuButton } from 'mono-svelte'
|
||||
import {
|
||||
@@ -21,7 +21,7 @@
|
||||
ShieldExclamation,
|
||||
} from 'svelte-hero-icons'
|
||||
|
||||
let { data } = $props();
|
||||
let { data } = $props()
|
||||
|
||||
let my_user = $derived(data.my_user!.local_user_view)
|
||||
</script>
|
||||
@@ -54,7 +54,7 @@
|
||||
]}
|
||||
>
|
||||
{#snippet nameDetail()}
|
||||
<span class="text-sm flex gap-0 items-center w-max" >
|
||||
<span class="text-sm flex gap-0 items-center w-max">
|
||||
@
|
||||
<UserLink
|
||||
showInstance
|
||||
@@ -70,11 +70,11 @@
|
||||
dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text-zinc-300 transition-colors"
|
||||
>
|
||||
{#snippet title()}
|
||||
<span class="flex items-center gap-1">
|
||||
<span class="flex items-center gap-1">
|
||||
<ShieldIcon width={14} filled />
|
||||
{$t('routes.profile.moderates')}
|
||||
</span>
|
||||
{/snippet}
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={data.moderates?.map((m) => ({
|
||||
id: m.community.id,
|
||||
@@ -88,7 +88,7 @@
|
||||
{/if}
|
||||
</EntityHeader>
|
||||
|
||||
{#if $userSettings.debugInfo}
|
||||
{#if settings.debugInfo}
|
||||
<pre>
|
||||
{JSON.stringify(my_user, undefined, 4)}
|
||||
</pre>
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import { searchParam } from '$lib/util'
|
||||
import { searchParam } from '$lib/util.svelte'
|
||||
import { flip } from 'svelte/animate'
|
||||
import PictrsImage from './PictrsImage.svelte'
|
||||
import { expoInOut, expoOut } from 'svelte/easing'
|
||||
|
||||
let { data = $bindable() } = $props();
|
||||
let { data = $bindable() } = $props()
|
||||
</script>
|
||||
|
||||
<Header pageHeader>{$t('routes.profile.media.title')}</Header>
|
||||
@@ -22,9 +22,9 @@
|
||||
data.images.findIndex(
|
||||
(i) =>
|
||||
i.local_image.pictrs_delete_token ==
|
||||
image.local_image.pictrs_delete_token
|
||||
image.local_image.pictrs_delete_token,
|
||||
),
|
||||
1
|
||||
1,
|
||||
)
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { client } from '$lib/lemmy.js'
|
||||
import { error } from '@sveltejs/kit'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/auth'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { instance } from '$lib/instance'
|
||||
import { client } from '$lib/lemmy'
|
||||
import { t } from '$lib/translations'
|
||||
import { instanceToURL } from '$lib/util'
|
||||
import { instanceToURL } from '$lib/util.svelte'
|
||||
import type { LocalImage } from 'lemmy-js-client'
|
||||
import { Button, Material, toast } from 'mono-svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
@@ -33,10 +33,10 @@
|
||||
}
|
||||
|
||||
interface Props {
|
||||
image: LocalImage;
|
||||
image: LocalImage
|
||||
}
|
||||
|
||||
let { image }: Props = $props();
|
||||
let { image }: Props = $props()
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
@@ -59,8 +59,8 @@
|
||||
class="ml-auto"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={ArrowDownTray} size="16" mini />
|
||||
{/snippet}
|
||||
<Icon src={ArrowDownTray} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
<Button
|
||||
title={$t('post.actions.more.delete')}
|
||||
@@ -70,8 +70,8 @@
|
||||
disabled={loading}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={Trash} size="16" mini color="text-red-500" />
|
||||
{/snippet}
|
||||
<Icon src={Trash} size="16" mini color="text-red-500" />
|
||||
{/snippet}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,4 +1,4 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { getItemPublished } from '$lib/lemmy/item.js'
|
||||
import type { SortType } from 'lemmy-js-client'
|
||||
|
||||
Reference in new issue
Block a user