perf: fetch server and user details in parallel

zio/stable
Daniel Roe 2022-12-04 13:12:16 +00:00
parent 8537c8ee54
commit 20d8aa7e75
No known key found for this signature in database
GPG Key ID: 22D5008E4F5D9B55
1 changed files with 7 additions and 4 deletions

View File

@ -49,14 +49,17 @@ export async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: Ac
else { else {
try { try {
const me = await masto.accounts.verifyCredentials() const [me, server] = await Promise.all([
masto.accounts.verifyCredentials(),
masto.instances.fetch(),
])
user.account = me user.account = me
currentUserId.value = me.id
servers.value[me.id] = server
if (!users.value.some(u => u.server === user.server && u.token === user.token)) if (!users.value.some(u => u.server === user.server && u.token === user.token))
users.value.push(user as UserLogin) users.value.push(user as UserLogin)
currentUserId.value = me.id
servers.value[me.id] = await masto.instances.fetch()
} }
catch { catch {
await signout() await signout()