aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-01-29 20:25:51 +0800
committerFabio Berger <me@fabioberger.com>2018-01-29 20:25:51 +0800
commit6c1409b00db68dcd88b42806efef1e91bb1abed2 (patch)
treef5b362a0306474ea46bc72e3d0dc43786191888a /packages
parent542a1a11b9adc2db07e99cf1cba4b4f6fb24983d (diff)
downloaddexon-sol-tools-6c1409b00db68dcd88b42806efef1e91bb1abed2.tar
dexon-sol-tools-6c1409b00db68dcd88b42806efef1e91bb1abed2.tar.gz
dexon-sol-tools-6c1409b00db68dcd88b42806efef1e91bb1abed2.tar.bz2
dexon-sol-tools-6c1409b00db68dcd88b42806efef1e91bb1abed2.tar.lz
dexon-sol-tools-6c1409b00db68dcd88b42806efef1e91bb1abed2.tar.xz
dexon-sol-tools-6c1409b00db68dcd88b42806efef1e91bb1abed2.tar.zst
dexon-sol-tools-6c1409b00db68dcd88b42806efef1e91bb1abed2.zip
Fix bug related to balance/allowance fetching being async
Diffstat (limited to 'packages')
-rw-r--r--packages/website/ts/components/token_balances.tsx14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx
index ecafe5432..776ccb16e 100644
--- a/packages/website/ts/components/token_balances.tsx
+++ b/packages/website/ts/components/token_balances.tsx
@@ -133,6 +133,20 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
if (!_.isEqual(nextProps.trackedTokens, this.props.trackedTokens)) {
const newTokens = _.difference(nextProps.trackedTokens, this.props.trackedTokens);
const newTokenAddresses = _.map(newTokens, token => token.address);
+ // Add placeholder entry for this token to the state, since fetching the
+ // balance/allowance is asynchronous
+ const trackedTokenStateByAddress = this.state.trackedTokenStateByAddress;
+ for (const tokenAddress of newTokenAddresses) {
+ trackedTokenStateByAddress[tokenAddress] = {
+ balance: new BigNumber(0),
+ allowance: new BigNumber(0),
+ isLoaded: false,
+ };
+ }
+ this.setState({
+ trackedTokenStateByAddress,
+ });
+ // Fetch the actual balance/allowance.
this._fetchBalancesAndAllowancesAsync(newTokenAddresses);
}
}