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,
|
||||
|
||||
Reference in new issue
Block a user