Skip to content

Commit

Permalink
fix: skip empty account get staking (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 authored Jun 7, 2022
1 parent 11024c2 commit 2130240
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/providers/staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,20 @@ export const StakingProvider = ({ children }: React.PropsWithChildren<unknown>)
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(() => {
Expand Down

0 comments on commit 2130240

Please sign in to comment.