From 1635f1bab08f7fb46b0c1451fb89678e720ccc76 Mon Sep 17 00:00:00 2001 From: kujtimprenkuSQA <95851345+kujtimprenkuSQA@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:51:23 +0200 Subject: [PATCH] Change the logic for waiting about the isSignedIn() (#945) --- packages/sender/src/lib/sender.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/sender/src/lib/sender.ts b/packages/sender/src/lib/sender.ts index 15cae127b..a8a6d48e4 100644 --- a/packages/sender/src/lib/sender.ts +++ b/packages/sender/src/lib/sender.ts @@ -102,6 +102,16 @@ const Sender: WalletBehaviourFactory = async ({ }; const getAccounts = async (): Promise> => { + // Add extra wait to ensure Sender's sign in status is read from the + // browser extension background env. + // Check for isSignedIn() in only if selectedWalletId is set. + const { selectedWalletId } = store.getState(); + if (selectedWalletId) { + await waitFor(() => !!_state.wallet?.isSignedIn(), { + timeout: 1000, + }).catch(); + } + const accountId = _state.wallet.getAccountId(); if (!accountId) { @@ -322,15 +332,6 @@ export function setupSender({ const installed = await isInstalled(); - // Add extra wait to ensure Sender's sign in status is read from the - // browser extension background env. - // Check for isSignedIn() in only if extension is installed. - if (installed) { - await waitFor(() => !!window.near?.isSignedIn(), { timeout: 200 }).catch( - () => false - ); - } - return { id: "sender", type: "injected",