From 0314822eca3496af13ded2e6b03fb1d2e36bb92f Mon Sep 17 00:00:00 2001 From: heisenberg Date: Thu, 14 Sep 2023 11:27:52 +0800 Subject: [PATCH 1/2] fix: ignore error when getting address info on address management page --- src/ui/views/HDManager/AccountList.tsx | 2 +- src/ui/views/HDManager/utils.tsx | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ui/views/HDManager/AccountList.tsx b/src/ui/views/HDManager/AccountList.tsx index 17e6e9a68d2..9f532f980d5 100644 --- a/src/ui/views/HDManager/AccountList.tsx +++ b/src/ui/views/HDManager/AccountList.tsx @@ -87,7 +87,7 @@ export const AccountList: React.FC = ({ React.useEffect(() => { if (!hiddenInfo) { - createTask(() => fetchAccountsInfo(wallet, data ?? []).then(setList)); + fetchAccountsInfo(wallet, data ?? []).then(setList); } else { setList(data ?? []); } diff --git a/src/ui/views/HDManager/utils.tsx b/src/ui/views/HDManager/utils.tsx index 89820912fb9..ad418e18b33 100644 --- a/src/ui/views/HDManager/utils.tsx +++ b/src/ui/views/HDManager/utils.tsx @@ -8,6 +8,7 @@ import * as Sentry from '@sentry/browser'; import { KEYRING_CLASS } from '@/constant'; import { useRabbyDispatch } from '@/ui/store'; import { useTranslation } from 'react-i18next'; +import { isFunction } from 'lodash'; export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); @@ -40,7 +41,7 @@ export const fetchAccountsInfo = async ( } } - let chains: Account['chains']; + let chains: Account['chains'] = []; try { chains = await wallet.openapi.usedChainList(account.address); } catch (e) { @@ -59,11 +60,13 @@ export const fetchAccountsInfo = async ( } // find firstTxTime - chains?.forEach((chain: any) => { - if (chain.born_at) { - firstTxTime = Math.min(firstTxTime ?? Infinity, chain.born_at); - } - }); + if (isFunction(chains?.forEach)) { + chains?.forEach((chain: any) => { + if (chain.born_at) { + firstTxTime = Math.min(firstTxTime ?? Infinity, chain.born_at); + } + }); + } const accountInfo: Account = { ...account, From 48cf13aad14807d37b86339a6b40ef647534823f Mon Sep 17 00:00:00 2001 From: heisenberg Date: Thu, 14 Sep 2023 11:30:04 +0800 Subject: [PATCH 2/2] fix: balance --- src/ui/views/HDManager/AccountList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/views/HDManager/AccountList.tsx b/src/ui/views/HDManager/AccountList.tsx index 9f532f980d5..e9fc25cf860 100644 --- a/src/ui/views/HDManager/AccountList.tsx +++ b/src/ui/views/HDManager/AccountList.tsx @@ -362,7 +362,7 @@ export const AccountList: React.FC = ({ render={(balance, record) => hiddenInfo ? ( - ) : record.chains?.length ? ( + ) : record.chains?.length && balance ? ( `$${splitNumberByStep(balance.toFixed(2))}` ) : null }