1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-19 23:40:07 +00:00

fix(settings): refresh profile after initted

This commit is contained in:
三咲智子 2023-01-02 03:42:11 +08:00
parent 496da96072
commit fbf1906bd4
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
2 changed files with 13 additions and 18 deletions

View file

@ -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) {

View file

@ -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>