diff --git a/apps/mobile/src/components2024/NoLongerSupports/useNoLongerSupports.ts b/apps/mobile/src/components2024/NoLongerSupports/useNoLongerSupports.ts index 0a37c63a5..ef243afd4 100644 --- a/apps/mobile/src/components2024/NoLongerSupports/useNoLongerSupports.ts +++ b/apps/mobile/src/components2024/NoLongerSupports/useNoLongerSupports.ts @@ -6,6 +6,8 @@ import { removeGlobalBottomSheetModal2024, } from '../GlobalBottomSheetModal'; import { MODAL_ID, MODAL_NAMES } from '../GlobalBottomSheetModal/types'; +import { apisAccount } from '@/core/apis'; +import { redirectToAddAddressEntry } from '@/utils/navigation'; export const useNoLongerSupports = () => { const { accounts } = useAccounts({ @@ -20,6 +22,12 @@ export const useNoLongerSupports = () => { removeAccount(account); } }); + + apisAccount.hasVisibleAccounts().then(hasRestAccounts => { + if (!hasRestAccounts) { + redirectToAddAddressEntry({ action: 'resetTo' }); + } + }); }, [accounts, removeAccount]); React.useEffect(() => { diff --git a/apps/mobile/src/core/apis/account.ts b/apps/mobile/src/core/apis/account.ts index 17a15af17..b635d9f70 100644 --- a/apps/mobile/src/core/apis/account.ts +++ b/apps/mobile/src/core/apis/account.ts @@ -18,10 +18,11 @@ function ensureDisplayKeyring(keyring: KeyringIntf | DisplayKeyring) { } export async function hasVisibleAccounts() { - return keyringService.getCountOfAccountsInKeyring() > 0; + const restAccountsCount = await keyringService.getCountOfAccountsInKeyring(); + return restAccountsCount > 0; } -export async function getAllVisibleAccounts(): Promise { +async function getAllVisibleAccounts(): Promise { const typedAccounts = await keyringService.getAllTypedVisibleAccounts(); return typedAccounts.map(account => ({ diff --git a/apps/mobile/src/screens/Home/MultiAddressHome.tsx b/apps/mobile/src/screens/Home/MultiAddressHome.tsx index d12c15405..66bf56957 100644 --- a/apps/mobile/src/screens/Home/MultiAddressHome.tsx +++ b/apps/mobile/src/screens/Home/MultiAddressHome.tsx @@ -221,8 +221,7 @@ function MultiAddressHome(): JSX.Element { const detectHasAccounts = useMemoizedFn(async () => { const result = { redirectAction: null as Function | null }; - const hasAccountsInKeyring = - (await apisAccount.getAllVisibleAccounts()).length > 0; + const hasAccountsInKeyring = await apisAccount.hasVisibleAccounts(); if (!hasAccountsInKeyring) { result.redirectAction = () => { diff --git a/packages/service-keyring/src/keyringService.ts b/packages/service-keyring/src/keyringService.ts index e85b7293c..b0e8ea745 100644 --- a/packages/service-keyring/src/keyringService.ts +++ b/packages/service-keyring/src/keyringService.ts @@ -160,8 +160,8 @@ export class KeyringService extends RNEventEmitter { // } async getCountOfAccountsInKeyring() { - const accus = await this.getAllTypedVisibleAccounts(); - return accus.length; + const accounts = await this.getAllTypedVisibleAccounts(); + return accounts.length; } /**