mirror of https://github.com/certusone/oyster.git
make sure prices are queried only once
This commit is contained in:
parent
3bf9eaad7a
commit
227937ab46
|
@ -2,7 +2,7 @@ import { EventEmitter } from '@oyster/common';
|
|||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import { MarketsContextState } from './market';
|
||||
|
||||
export const COINGECKO_POOL_INTERVAL = 10000; // 2 min
|
||||
export const COINGECKO_POOL_INTERVAL = 1000 * 30; // 30 sec
|
||||
export const COINGECKO_API = 'https://api.coingecko.com/api/v3/';
|
||||
export const COINGECKO_COIN_LIST_API = `${COINGECKO_API}coins/list`;
|
||||
export const COINGECKO_COIN_PRICE_API = `${COINGECKO_API}simple/price`;
|
||||
|
|
|
@ -362,14 +362,14 @@ export const useWormholeAccounts = () => {
|
|||
}, [externalAssets, setAmountInUSD]);
|
||||
|
||||
useEffect(() => {
|
||||
if (externalAssets && coinList) {
|
||||
if (externalAssets && coinList && !loading) {
|
||||
dataSourcePriceQuery();
|
||||
}
|
||||
return () => {
|
||||
window.clearTimeout(coingeckoTimer.current);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [externalAssets, coinList, dataSourcePriceQuery]);
|
||||
}, [externalAssets, coinList, loading]);
|
||||
|
||||
return {
|
||||
loading,
|
||||
|
|
Loading…
Reference in New Issue