fix(settings): parse links in metadata

zio/stable
三咲智子 2023-01-03 06:00:23 +08:00
parent 8a0f9176fb
commit 26be3e5894
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { UpdateCredentialsParams } from 'masto' import type { UpdateCredentialsParams } from 'masto'
import { useForm } from 'slimeform' import { useForm } from 'slimeform'
import { parse } from 'ultrahtml'
definePageMeta({ definePageMeta({
middleware: 'auth', middleware: 'auth',
@ -19,7 +20,13 @@ const { form, reset, submitter, dirtyFields, isError } = useForm({
form: () => { form: () => {
// For complex types of objects, a deep copy is required to ensure correct comparison of initial and modified values // 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) => { 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 { return {
displayName: account?.displayName ?? '', displayName: account?.displayName ?? '',