From 91b234918d52769430d746702523938fecfdd4e2 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Thu, 3 Aug 2023 17:34:41 -0700 Subject: [PATCH] fix: prevent api client from starting to early --- store/server.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/store/server.ts b/store/server.ts index abfd72126..4207fd671 100644 --- a/store/server.ts +++ b/store/server.ts @@ -695,11 +695,19 @@ export const useServerStore = defineStore('server', () => { console.debug('[watch:registeredWithValidApiKey]', newVal, oldVal); if (oldVal) { console.debug('[watch:registeredWithValidApiKey] no apiKey, stop unraid-api client'); - unraidApiStore.closeUnraidApiClient(); + return unraidApiStore.closeUnraidApiClient(); } if (newVal) { - console.debug('[watch:registeredWithValidApiKey] new apiKey, start unraid-api client'); - unraidApiStore.createApolloClient(); + // if this is just after sign in, let's delay the start by a few seconds to give unraid-api time to update + if (accountStore.accountActionType === 'signIn') { + console.debug('[watch:registeredWithValidApiKey] delay start unraid-api client'); + return setTimeout(() => { + unraidApiStore.createApolloClient(); + }, 2000); + } else { + console.debug('[watch:registeredWithValidApiKey] new apiKey, start unraid-api client'); + return unraidApiStore.createApolloClient(); + } } }); /**