mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
refresh interval tweaks (#257)
This commit is contained in:
parent
fa7de2eeb4
commit
7f2a5e7515
@ -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<MarketStatsResponse>()
|
||||
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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])
|
||||
|
||||
|
@ -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
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user