fix(settings): refresh profile after initted
This commit is contained in:
parent
496da96072
commit
fbf1906bd4
|
@ -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) {
|
||||
|
|
|
@ -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({
|
|||
}),
|
||||
})
|
||||
|
||||
watch(isMastoInitialised, async (val) => {
|
||||
if (!val)
|
||||
return
|
||||
|
||||
// Keep the information to be edited up to date
|
||||
invoke(async () => {
|
||||
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>
|
||||
|
|
Loading…
Reference in a new issue