refactor: sync masto (#1121)

This commit is contained in:
三咲智子 Kevin Deng 2023-01-15 16:38:02 +08:00 committed by GitHub
parent eb1f769e32
commit 4422a57f49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 397 additions and 367 deletions

View file

@ -13,6 +13,8 @@ useHeadFixed({
title: () => `${t('settings.profile.appearance.title')} | ${t('nav.settings')}`,
})
const { client } = $(useMasto())
const account = $computed(() => currentUser.value?.account)
const onlineSrc = $computed(() => ({
@ -57,7 +59,7 @@ const { submit, submitting } = submitter(async ({ dirtyFields }) => {
if (!isCanSubmit.value)
return
const res = await useMasto().v1.accounts.updateCredentials(dirtyFields.value as mastodon.v1.UpdateCredentialsParams)
const res = await client.v1.accounts.updateCredentials(dirtyFields.value as mastodon.v1.UpdateCredentialsParams)
.then(account => ({ account }))
.catch((error: Error) => ({ error }))
@ -67,18 +69,20 @@ const { submit, submitting } = submitter(async ({ dirtyFields }) => {
return
}
setAccountInfo(account!.id, res.account)
currentUser.value!.account = res.account
reset()
})
const refreshInfo = async () => {
if (!currentUser.value)
return
// Keep the information to be edited up to date
await pullMyAccountInfo()
await refreshAccountInfo()
if (!isDirty)
reset()
}
onMastoInit(refreshInfo)
onHydrated(refreshInfo)
onReactivated(refreshInfo)
</script>