diff --git a/src/lib/components/input/Checkbox.svelte b/src/lib/components/input/Checkbox.svelte index b0a2d27e..0e99f373 100644 --- a/src/lib/components/input/Checkbox.svelte +++ b/src/lib/components/input/Checkbox.svelte @@ -1,11 +1,11 @@ - + + import { profile } from '$lib/auth.js' + import Button from '$lib/components/input/Button.svelte' + import Checkbox from '$lib/components/input/Checkbox.svelte' + import TextInput from '$lib/components/input/TextInput.svelte' + import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' + import Card from '$lib/components/ui/Card.svelte' + import { toast } from '$lib/components/ui/toasts/toasts.js' + import { getClient } from '$lib/lemmy.js' + import type { SaveUserSettings } from 'lemmy-js-client' + import { onMount } from 'svelte' + + export let data + + let formData: Omit | undefined = { + ...data.local_user_view?.local_user, + ...data.local_user_view?.person, + } + + async function save() { + if (!formData || !$profile?.jwt) return + + loading = true + + try { + const res = await getClient().saveUserSettings({ + auth: $profile.jwt, + ...formData, + }) + toast({ + content: 'Saved your user settings.', + type: 'success', + }) + if (res.verify_email_sent) { + toast({ + content: 'A verification email was sent.', + type: 'info', + }) + } + } catch (err) { + toast({ + content: err as any, + type: 'error', + }) + } + loading = false + } + + let loading = false + + + + User settings + {#if data.local_user_view?.local_user && formData} + + + + + Show NSFW content + Show Scores + Bot Account + + Show Bot Accounts + + Show Read Posts + + + Save + + {:else} + + The API didn't return your user settings. + + {/if} + diff --git a/src/routes/profile/settings/+page.ts b/src/routes/profile/settings/+page.ts new file mode 100644 index 00000000..52d6d377 --- /dev/null +++ b/src/routes/profile/settings/+page.ts @@ -0,0 +1,7 @@ +import { profile } from '$lib/auth.js' +import { getClient } from '$lib/lemmy.js' +import { get } from 'svelte/store' + +export async function load() { + return (await getClient().getSite({ auth: get(profile)?.jwt })).my_user +} diff --git a/src/routes/profile/user/+page.ts b/src/routes/profile/user/+page.ts deleted file mode 100644 index 4f8d764b..00000000 --- a/src/routes/profile/user/+page.ts +++ /dev/null @@ -1,3 +0,0 @@ -export async function load({ parent }) { - return await parent() -}