fix(settings): refresh profile after initted

pull/668/head
三咲智子 2023-01-02 03:42:11 +08:00
rodzic 496da96072
commit fbf1906bd4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 69992F2250DFD93E
2 zmienionych plików z 13 dodań i 18 usunięć

Wyświetl plik

@ -139,8 +139,8 @@ export function setAccountInfo(userId: string, account: AccountCredentials) {
}
export async function pullMyAccountInfo() {
const me = await useMasto().accounts.verifyCredentials()
setAccountInfo(currentUserId.value, me)
const account = await useMasto().accounts.verifyCredentials()
setAccountInfo(currentUserId.value, account)
}
export function getUsersIndexByUserId(userId: string) {

Wyświetl plik

@ -1,5 +1,4 @@
<script lang="ts" setup>
import { invoke } from '@vueuse/shared'
import { useForm } from 'slimeform'
definePageMeta({
@ -8,24 +7,17 @@ definePageMeta({
keepalive: false,
})
const router = useRouter()
const my = $computed(() => currentUser.value?.account)
watch($$(my), (value) => {
if (!value)
router.push('/')
})
const acccount = $computed(() => currentUser.value?.account)
const onlineSrc = $computed(() => ({
avatar: my?.avatar || '',
header: my?.header || '',
avatar: acccount?.avatar || '',
header: acccount?.header || '',
}))
const { form, reset, submitter, dirtyFields, isError } = useForm({
form: () => ({
displayName: my?.displayName ?? '',
note: my?.source.note.replaceAll('\r', '') ?? '',
displayName: acccount?.displayName ?? '',
note: acccount?.source.note.replaceAll('\r', '') ?? '',
avatar: null as null | File,
header: null as null | File,
@ -37,8 +29,11 @@ const { form, reset, submitter, dirtyFields, isError } = useForm({
}),
})
// Keep the information to be edited up to date
invoke(async () => {
watch(isMastoInitialised, async (val) => {
if (!val)
return
// Keep the information to be edited up to date
await pullMyAccountInfo()
reset()
})
@ -56,7 +51,7 @@ const { submit, submitting } = submitter(async ({ dirtyFields }) => {
return
}
setAccountInfo(my!.id, res.account)
setAccountInfo(acccount!.id, res.account)
reset()
})
</script>