aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux
diff options
context:
space:
mode:
authorSteve Klebanoff <steve@0xproject.com>2018-11-10 08:02:09 +0800
committerGitHub <noreply@github.com>2018-11-10 08:02:09 +0800
commit26cbe7ae6646d97c286e58756c23a93de32ae37b (patch)
tree96943e8dd87f0e3ef8c994101bce5a16a47082ea /packages/instant/src/redux
parent2c585bfbdc4940e3e6089ac1cf595dd009b141d2 (diff)
parentfd83ca2cb893ab7cc027efd6829ba2eb07cdb539 (diff)
downloaddexon-sol-tools-26cbe7ae6646d97c286e58756c23a93de32ae37b.tar
dexon-sol-tools-26cbe7ae6646d97c286e58756c23a93de32ae37b.tar.gz
dexon-sol-tools-26cbe7ae6646d97c286e58756c23a93de32ae37b.tar.bz2
dexon-sol-tools-26cbe7ae6646d97c286e58756c23a93de32ae37b.tar.lz
dexon-sol-tools-26cbe7ae6646d97c286e58756c23a93de32ae37b.tar.xz
dexon-sol-tools-26cbe7ae6646d97c286e58756c23a93de32ae37b.tar.zst
dexon-sol-tools-26cbe7ae6646d97c286e58756c23a93de32ae37b.zip
Merge pull request #1237 from 0xProject/feature/instant/buy-quote-heartbeat
[instant] Heartbeats for account info and buy quotes
Diffstat (limited to 'packages/instant/src/redux')
-rw-r--r--packages/instant/src/redux/async_data.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts
index a8f632009..a47c7a605 100644
--- a/packages/instant/src/redux/async_data.ts
+++ b/packages/instant/src/redux/async_data.ts
@@ -2,7 +2,7 @@ import { AssetProxyId } from '@0x/types';
import * as _ from 'lodash';
import { BIG_NUMBER_ZERO } from '../constants';
-import { AccountState, ERC20Asset } from '../types';
+import { AccountState, ERC20Asset, OrderProcessState } from '../types';
import { assetUtils } from '../util/asset';
import { buyQuoteUpdater } from '../util/buy_quote_updater';
import { coinbaseApi } from '../util/coinbase_api';
@@ -36,10 +36,11 @@ export const asyncData = {
store.dispatch(actions.setAvailableAssets([]));
}
},
- fetchAccountInfoAndDispatchToStore: async (store: Store) => {
+ fetchAccountInfoAndDispatchToStore: async (options: { store: Store; shouldSetToLoading: boolean }) => {
+ const { store, shouldSetToLoading } = options;
const { providerState } = store.getState();
const web3Wrapper = providerState.web3Wrapper;
- if (providerState.account.state !== AccountState.Loading) {
+ if (shouldSetToLoading && providerState.account.state !== AccountState.Loading) {
store.dispatch(actions.setAccountStateLoading());
}
let availableAddresses: string[];
@@ -74,12 +75,14 @@ export const asyncData = {
return;
}
},
- fetchCurrentBuyQuoteAndDispatchToStore: async (store: Store) => {
- const { providerState, selectedAsset, selectedAssetAmount, affiliateInfo } = store.getState();
+ fetchCurrentBuyQuoteAndDispatchToStore: async (options: { store: Store; shouldSetPending: boolean }) => {
+ const { store, shouldSetPending } = options;
+ const { buyOrderState, providerState, selectedAsset, selectedAssetAmount, affiliateInfo } = store.getState();
const assetBuyer = providerState.assetBuyer;
if (
!_.isUndefined(selectedAssetAmount) &&
!_.isUndefined(selectedAsset) &&
+ buyOrderState.processState === OrderProcessState.None &&
selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20
) {
await buyQuoteUpdater.updateBuyQuoteAsync(
@@ -87,6 +90,7 @@ export const asyncData = {
store.dispatch,
selectedAsset as ERC20Asset,
selectedAssetAmount,
+ shouldSetPending,
affiliateInfo,
);
}