aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-10-23 01:56:11 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-10-23 01:56:11 +0800
commit2bb53d5b1df7cebaf6fd2e17640729f7401d7162 (patch)
tree68932954e5b157accc7a1c90ecd7f6dc53adf039 /packages/website
parent38eaacdd4425ec73761a95bd5b035b15e6fe675f (diff)
downloaddexon-sol-tools-2bb53d5b1df7cebaf6fd2e17640729f7401d7162.tar
dexon-sol-tools-2bb53d5b1df7cebaf6fd2e17640729f7401d7162.tar.gz
dexon-sol-tools-2bb53d5b1df7cebaf6fd2e17640729f7401d7162.tar.bz2
dexon-sol-tools-2bb53d5b1df7cebaf6fd2e17640729f7401d7162.tar.lz
dexon-sol-tools-2bb53d5b1df7cebaf6fd2e17640729f7401d7162.tar.xz
dexon-sol-tools-2bb53d5b1df7cebaf6fd2e17640729f7401d7162.tar.zst
dexon-sol-tools-2bb53d5b1df7cebaf6fd2e17640729f7401d7162.zip
fix(website): do not fetch balances for empty tokens
Diffstat (limited to 'packages/website')
-rw-r--r--packages/website/ts/components/portal/portal.tsx19
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx
index 2299881c4..94ab63ac6 100644
--- a/packages/website/ts/components/portal/portal.tsx
+++ b/packages/website/ts/components/portal/portal.tsx
@@ -210,12 +210,16 @@ export class Portal extends React.Component<PortalProps, PortalState> {
isLoaded: false,
};
}
- this.setState({
- trackedTokenStateByAddress,
- });
- // Fetch the actual balance/allowance.
- // tslint:disable-next-line:no-floating-promises
- this._fetchBalancesAndAllowancesAsync(newTokenAddresses);
+ this.setState(
+ {
+ trackedTokenStateByAddress,
+ },
+ () => {
+ // Fetch the actual balance/allowance.
+ // tslint:disable-next-line:no-floating-promises
+ this._fetchBalancesAndAllowancesAsync(newTokenAddresses);
+ },
+ );
}
}
public render(): React.ReactNode {
@@ -644,6 +648,9 @@ export class Portal extends React.Component<PortalProps, PortalState> {
}
private async _fetchBalancesAndAllowancesAsync(tokenAddresses: string[]): Promise<void> {
+ if (_.isEmpty(tokenAddresses)) {
+ return;
+ }
const trackedTokenStateByAddress = this.state.trackedTokenStateByAddress;
const userAddressIfExists = _.isEmpty(this.props.userAddress) ? undefined : this.props.userAddress;
const balancesAndAllowances = await Promise.all(