diff --git a/src/components/molecules/MarketStats.tsx b/src/components/molecules/MarketStats.tsx index 589466b95..cadbbb13d 100644 --- a/src/components/molecules/MarketStats.tsx +++ b/src/components/molecules/MarketStats.tsx @@ -17,6 +17,8 @@ interface MarketStatsResponse { datatoken: number } +const refreshInterval = 60000 // 60 sec. + export default function MarketStats(): ReactElement { const [ref, inView] = useInView() const [stats, setStats] = useState() @@ -40,8 +42,8 @@ export default function MarketStats(): ReactElement { } } - // Update every 10 sec. when in viewport - const interval = setInterval(getStats, 10000) + // Update periodically when in viewport + const interval = setInterval(getStats, refreshInterval) if (!inView) { clearInterval(interval) diff --git a/src/components/organisms/AssetActions/Pool/index.tsx b/src/components/organisms/AssetActions/Pool/index.tsx index 39279afbd..54460e465 100644 --- a/src/components/organisms/AssetActions/Pool/index.tsx +++ b/src/components/organisms/AssetActions/Pool/index.tsx @@ -41,7 +41,7 @@ const contentQuery = graphql` } ` -const refreshInterval = 10000 // 10 sec. +const refreshInterval = 15000 // 15 sec. export default function Pool({ ddo }: { ddo: DDO }): ReactElement { const data = useStaticQuery(contentQuery) diff --git a/src/components/organisms/AssetActions/Trade/index.tsx b/src/components/organisms/AssetActions/Trade/index.tsx index c97736d31..87d16daa5 100644 --- a/src/components/organisms/AssetActions/Trade/index.tsx +++ b/src/components/organisms/AssetActions/Trade/index.tsx @@ -4,7 +4,7 @@ import { DDO } from '@oceanprotocol/lib' import FormTrade from './FormTrade' import TokenBalance from '../../../../@types/TokenBalance' -const refreshInterval = 6000 // 6 sec, if the interval is bellow 3-5 seconds the price will be 0 all the time +const refreshInterval = 10000 // 10 sec, if the interval is bellow 3-5 seconds the price will be 0 all the time export default function Trade({ ddo }: { ddo: DDO }): ReactElement { const { ocean, balance, accountId, networkId, refreshBalance } = useOcean() diff --git a/src/components/organisms/AssetContent/Pricing/FormPricing/Dynamic.tsx b/src/components/organisms/AssetContent/Pricing/FormPricing/Dynamic.tsx index a7acb0fc5..7d26a91a3 100644 --- a/src/components/organisms/AssetContent/Pricing/FormPricing/Dynamic.tsx +++ b/src/components/organisms/AssetContent/Pricing/FormPricing/Dynamic.tsx @@ -15,6 +15,8 @@ import { DDO } from '@oceanprotocol/lib' import Price from './Price' import Decimal from 'decimal.js' +const refreshInterval = 10000 // 10 sec. + export default function Dynamic({ ddo, content @@ -74,7 +76,7 @@ export default function Dynamic({ if (!account) return refreshBalance() - const balanceInterval = setInterval(() => refreshBalance(), 10000) // 10 sec. + const balanceInterval = setInterval(() => refreshBalance(), refreshInterval) return () => { clearInterval(balanceInterval) diff --git a/src/components/templates/AssetDetails.tsx b/src/components/templates/AssetDetails.tsx index e72075263..4972e4c58 100644 --- a/src/components/templates/AssetDetails.tsx +++ b/src/components/templates/AssetDetails.tsx @@ -50,7 +50,7 @@ export default function PageTemplateAssetDetails({ init() // Periodically try to get DDO when not present yet - const timer = !ddo && setInterval(() => init(), 2000) + const timer = !ddo && setInterval(() => init(), 5000) return () => clearInterval(timer) }, [ddo, did, config.metadataCacheUri]) diff --git a/src/providers/Prices.tsx b/src/providers/Prices.tsx index 3a8d88216..5242cd67a 100644 --- a/src/providers/Prices.tsx +++ b/src/providers/Prices.tsx @@ -21,6 +21,8 @@ const initialData: PricesValue = { btc: 0.0 } +const refreshInterval = 120000 // 120 sec. + const PricesContext = createContext(null) export default function PricesProvider({ @@ -43,7 +45,7 @@ export default function PricesProvider({ // Fetch new prices periodically with swr useSWR(url, fetchData, { - refreshInterval: 60000, // 60 sec. + refreshInterval, onSuccess })