Don't start heartbeat if no account

This commit is contained in:
Steve Klebanoff
2018-11-09 15:40:13 -08:00
parent 93054ae52b
commit 4072076965

View File

@@ -11,7 +11,7 @@ import { asyncData } from '../redux/async_data';
import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
import { store, Store } from '../redux/store';
import { fonts } from '../style/fonts';
import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
import { AffiliateInfo, AssetMetaData, Network, OrderSource, AccountState } from '../types';
import { assetUtils } from '../util/asset';
import { errorFlasher } from '../util/error_flasher';
import { gasPriceEstimator } from '../util/gas_price_estimator';
@@ -99,11 +99,13 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
}
this._accountUpdateHeartbeat = generateAccountHeartbeater({
store: this._store,
shouldPerformImmediatelyOnStart: true,
});
this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
if (state.providerState.account.state !== AccountState.None) {
this._accountUpdateHeartbeat = generateAccountHeartbeater({
store: this._store,
shouldPerformImmediatelyOnStart: true,
});
this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
}
this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({
store: this._store,