From 6ffad619266e4945a4a3364edbd07d9c9c76e808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bego=C3=B1a=20=C3=81lvarez=20de=20la=20Cruz?= Date: Wed, 11 Oct 2023 10:36:34 +0200 Subject: [PATCH] fix: last selected account id not found (#7572) --- .../lib/core/profile/actions/active-profile/login.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/shared/lib/core/profile/actions/active-profile/login.ts b/packages/shared/lib/core/profile/actions/active-profile/login.ts index af08b25b4a3..e159bf58fdd 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/login.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/login.ts @@ -140,7 +140,14 @@ export async function login(loginOptions?: ILoginOptions): Promise { pollLedgerNanoStatus() } - setSelectedAccount(lastUsedAccountIndex ?? get(activeAccounts)?.[0]?.index ?? null) + let initialSelectedAccountindex = get(activeAccounts)?.[0]?.index + if ( + lastUsedAccountIndex && + get(activeAccounts)?.find((_account) => _account.index === lastUsedAccountIndex) + ) { + initialSelectedAccountindex = lastUsedAccountIndex + } + setSelectedAccount(initialSelectedAccountindex) lastActiveAt.set(new Date()) loggedIn.set(true) setTimeout(() => {