From 213024092ddf9e71bf211f0d85d9df3b3ed33d51 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 7 Jun 2022 17:59:39 +0800 Subject: [PATCH] fix: skip empty account get staking (#198) --- src/providers/staking.tsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/providers/staking.tsx b/src/providers/staking.tsx index 4bebae57..fca70415 100644 --- a/src/providers/staking.tsx +++ b/src/providers/staking.tsx @@ -121,18 +121,20 @@ export const StakingProvider = ({ children }: React.PropsWithChildren) const { takeWhileIsMounted } = useIsMountedOperator(); const updateStakingDerive = useCallback(() => { - from(api.derive.staking.account(account)) - .pipe( - tap(() => setIsStakingDeriveLoading(true)), - takeWhileIsMounted() - ) - .subscribe({ - next: (res) => { - setStakingDerive(res as unknown as DeriveStakingAccount); - setIsStakingDeriveLoading(false); - }, - error: () => setIsStakingDeriveLoading(false), - }); + if (account) { + from(api.derive.staking.account(account)) + .pipe( + tap(() => setIsStakingDeriveLoading(true)), + takeWhileIsMounted() + ) + .subscribe({ + next: (res) => { + setStakingDerive(res as unknown as DeriveStakingAccount); + setIsStakingDeriveLoading(false); + }, + error: () => setIsStakingDeriveLoading(false), + }); + } }, [api, account, takeWhileIsMounted]); const updateValidators = useCallback(() => {