From 20d8aa7e759cccee92790e95168bdd90757e6d81 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 4 Dec 2022 13:12:16 +0000 Subject: [PATCH] perf: fetch server and user details in parallel --- composables/users.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/composables/users.ts b/composables/users.ts index 019f67d8..547c7dc1 100644 --- a/composables/users.ts +++ b/composables/users.ts @@ -49,14 +49,17 @@ export async function loginTo(user?: Omit & { account?: Ac else { try { - const me = await masto.accounts.verifyCredentials() + const [me, server] = await Promise.all([ + masto.accounts.verifyCredentials(), + masto.instances.fetch(), + ]) + 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)) users.value.push(user as UserLogin) - - currentUserId.value = me.id - servers.value[me.id] = await masto.instances.fetch() } catch { await signout()