Skip to content

Commit

Permalink
Merge pull request #18 from ZigZagExchange/fix-refetch-intervals
Browse files Browse the repository at this point in the history
fix refetch intervals
  • Loading branch information
taureau75 authored Jun 17, 2023
2 parents 3fa38b7 + 8c3bd59 commit 486069b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions frontend/components/bridge/Bridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export enum BuyValidationState {
}

let LAST_DATA_UPDATE = Date.now()
let LIQUIDITY_INTERVAL: Object
let PRICES_INTERVAL: Object

function Bridge() {
const TRADING_FEE = 0.002
Expand Down Expand Up @@ -147,16 +145,11 @@ function Bridge() {
}, [destChainId])

useEffect(() => {
// For some reason this function gets triggered twice so the
// checks are to prevent the intervals from being set twice
if (!LIQUIDITY_INTERVAL) {
const refetchInterval = setInterval(() => {
fetchLiquidity()
LIQUIDITY_INTERVAL = setInterval(fetchLiquidity, 20000)
}
if (!PRICES_INTERVAL) {
fetchPrices()
PRICES_INTERVAL = setInterval(fetchPrices, 20000)
}
}, 20000)
return () => clearInterval(refetchInterval)
}, [])

// Fetch SPL Token balance
Expand Down

1 comment on commit 486069b

@vercel
Copy link

@vercel vercel bot commented on 486069b Jun 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.