From 230f92977618457e53539ad2bde0603cdeec811d Mon Sep 17 00:00:00 2001 From: Jubal Mabaquiao Date: Sat, 30 Dec 2023 01:44:15 +0800 Subject: [PATCH] check balance only when necessary (#234) --- app/ts/components/TokenPicker.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/ts/components/TokenPicker.tsx b/app/ts/components/TokenPicker.tsx index 7799cab3..ade60796 100644 --- a/app/ts/components/TokenPicker.tsx +++ b/app/ts/components/TokenPicker.tsx @@ -148,6 +148,7 @@ const AssetCard = ({ token }: { token?: ERC20Token }) => { } const AssetBalance = ({ token }: { token?: ERC20Token }) => { + const { stage } = useTokenManager() const { browserProvider, blockNumber } = useEthereumProvider() const { account } = useWallet() const { value: query, waitFor } = useAsyncState() @@ -167,7 +168,7 @@ const AssetBalance = ({ token }: { token?: ERC20Token }) => { } useSignalEffect(() => { - if (!blockNumber.value || account.value.state !== 'resolved') return + if (!stage.value || !blockNumber.value || account.value.state !== 'resolved') return getAssetBalance(account.value.value) })