fix(settings): parse links in metadata

pull/717/head
三咲智子 2023-01-03 06:00:23 +08:00
rodzic 8a0f9176fb
commit 26be3e5894
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 69992F2250DFD93E
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
<script lang="ts" setup>
import type { UpdateCredentialsParams } from 'masto'
import { useForm } from 'slimeform'
import { parse } from 'ultrahtml'
definePageMeta({
middleware: 'auth',
@ -19,7 +20,13 @@ const { form, reset, submitter, dirtyFields, isError } = useForm({
form: () => {
// For complex types of objects, a deep copy is required to ensure correct comparison of initial and modified values
const fieldsAttributes = Array.from({ length: 4 }, (_, i) => {
return { ...account?.fields?.[i] || { name: '', value: '' } }
const field = { ...account?.fields?.[i] || { name: '', value: '' } }
const linkElement = (parse(field.value)?.children?.[0])
if (linkElement && linkElement?.attributes?.href)
field.value = linkElement.attributes.href
return field
})
return {
displayName: account?.displayName ?? '',