feat: add profile image to settings
This commit is contained in:
1 parent
8ff8e710be
commit
017741a7ee
2 files changed
+8
-2
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "0.8.2",
|
"version": "0.8.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import Button from '$lib/components/input/Button.svelte'
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
import Checkbox from '$lib/components/input/Checkbox.svelte'
|
import Checkbox from '$lib/components/input/Checkbox.svelte'
|
||||||
|
import FileInput from '$lib/components/input/FileInput.svelte'
|
||||||
import TextInput from '$lib/components/input/TextInput.svelte'
|
import TextInput from '$lib/components/input/TextInput.svelte'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import Card from '$lib/components/ui/Card.svelte'
|
import Card from '$lib/components/ui/Card.svelte'
|
||||||
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { getClient, uploadImage } from '$lib/lemmy.js'
|
||||||
import type { SaveUserSettings } from 'lemmy-js-client'
|
import type { SaveUserSettings } from 'lemmy-js-client'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
@@ -16,15 +17,19 @@
|
|||||||
...data.local_user_view?.person,
|
...data.local_user_view?.person,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let profileImage: FileList | undefined
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
if (!formData || !$profile?.jwt) return
|
if (!formData || !$profile?.jwt) return
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
let pfp = profileImage ? await uploadImage(profileImage[0]) : undefined
|
||||||
const res = await getClient().saveUserSettings({
|
const res = await getClient().saveUserSettings({
|
||||||
auth: $profile.jwt,
|
auth: $profile.jwt,
|
||||||
...formData,
|
...formData,
|
||||||
|
avatar: pfp,
|
||||||
})
|
})
|
||||||
toast({
|
toast({
|
||||||
content: 'Saved your user settings.',
|
content: 'Saved your user settings.',
|
||||||
@@ -62,6 +67,7 @@
|
|||||||
label="Bio"
|
label="Bio"
|
||||||
previewButton
|
previewButton
|
||||||
/>
|
/>
|
||||||
|
<FileInput label="Profile image" image bind:files={profileImage} />
|
||||||
<TextInput label="Email" bind:value={formData.email} />
|
<TextInput label="Email" bind:value={formData.email} />
|
||||||
<TextInput
|
<TextInput
|
||||||
label="Matrix User"
|
label="Matrix User"
|
||||||
|
|||||||
Reference in new issue
Block a user