Skip to content

Commit

Permalink
Change the logic for waiting about the isSignedIn() (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
kujtimprenkuSQA authored Sep 27, 2023
1 parent ee7a187 commit 1635f1b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/sender/src/lib/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ const Sender: WalletBehaviourFactory<InjectedWallet> = async ({
};

const getAccounts = async (): Promise<Array<Account>> => {
// 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) {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 1635f1b

Please sign in to comment.