Merge pull request #727 from 0xProject/bug/website/fix-fetching-balances-on-wallet-login

Fix bug where we do not fetch balances on wallet login
This commit is contained in:
Francesco Agosti
2018-06-19 13:43:08 -07:00
committed by GitHub

View File

@@ -157,9 +157,6 @@ export class Portal extends React.Component<PortalProps, PortalState> {
} }
public componentWillMount(): void { public componentWillMount(): void {
this._blockchain = new Blockchain(this.props.dispatcher); this._blockchain = new Blockchain(this.props.dispatcher);
const trackedTokenAddresses = _.keys(this.state.trackedTokenStateByAddress);
// tslint:disable-next-line:no-floating-promises
this._fetchBalancesAndAllowancesAsync(trackedTokenAddresses);
} }
public componentWillUnmount(): void { public componentWillUnmount(): void {
this._blockchain.destroy(); this._blockchain.destroy();
@@ -170,6 +167,13 @@ export class Portal extends React.Component<PortalProps, PortalState> {
// become disconnected from their backing Ethereum node, changed user accounts, etc...) // become disconnected from their backing Ethereum node, changed user accounts, etc...)
this.props.dispatcher.resetState(); this.props.dispatcher.resetState();
} }
public componentDidUpdate(prevProps: PortalProps): void {
if (!prevProps.blockchainIsLoaded && this.props.blockchainIsLoaded) {
const trackedTokenAddresses = _.keys(this.state.trackedTokenStateByAddress);
// tslint:disable-next-line:no-floating-promises
this._fetchBalancesAndAllowancesAsync(trackedTokenAddresses);
}
}
public componentWillReceiveProps(nextProps: PortalProps): void { public componentWillReceiveProps(nextProps: PortalProps): void {
if (nextProps.networkId !== this.state.prevNetworkId) { if (nextProps.networkId !== this.state.prevNetworkId) {
// tslint:disable-next-line:no-floating-promises // tslint:disable-next-line:no-floating-promises