From 5e38cbd69c087e827ee4f4bec69b8e07103e46b8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 26 Jun 2018 13:58:31 -0700 Subject: Never use trackedTokenState when fetching new token state --- packages/website/ts/components/portal/portal.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'packages/website/ts/components') diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index df313415d..f06035f3f 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -152,9 +152,8 @@ export class Portal extends React.Component { } public componentDidUpdate(prevProps: PortalProps): void { if (!prevProps.blockchainIsLoaded && this.props.blockchainIsLoaded) { - const trackedTokenAddresses = _.map(this._getCurrentTrackedTokens(), token => token.address); // tslint:disable-next-line:no-floating-promises - this._fetchBalancesAndAllowancesAsync(trackedTokenAddresses); + this._fetchBalancesAndAllowancesAsync(this._getCurrentTrackedTokensAddresses()); } } public componentWillReceiveProps(nextProps: PortalProps): void { @@ -188,9 +187,8 @@ export class Portal extends React.Component { (nextProps.userAddress !== this.props.userAddress && nextProps.networkId === this.props.networkId) || nextProps.lastForceTokenStateRefetch !== this.props.lastForceTokenStateRefetch ) { - const trackedTokenAddresses = _.keys(this.state.trackedTokenStateByAddress); // tslint:disable-next-line:no-floating-promises - this._fetchBalancesAndAllowancesAsync(trackedTokenAddresses); + this._fetchBalancesAndAllowancesAsync(this._getCurrentTrackedTokensAddresses()); } const nextTrackedTokens = this._getTrackedTokens(nextProps.tokenByAddress); @@ -609,11 +607,12 @@ export class Portal extends React.Component { const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm; return isSmallScreen; } - private _getCurrentTrackedTokens(): Token[] { return this._getTrackedTokens(this.props.tokenByAddress); } - + private _getCurrentTrackedTokensAddresses(): string[] { + return _.map(this._getCurrentTrackedTokens(), token => token.address); + } private _getTrackedTokens(tokenByAddress: TokenByAddress): Token[] { const allTokens = _.values(tokenByAddress); const trackedTokens = _.filter(allTokens, t => t.isTracked); -- cgit v1.2.3