Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Fixed bug causing update to be triggered twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro Boscariol committed Jun 9, 2020
1 parent 2489fe8 commit 1205bdc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hooks/useTrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export function useTrades(): Trade[] {
// Thus, we check for new trades a few seconds after the 4min mark
const delay = getTimeRemainingInBatch() - 30

// Update now to not leave the interface empty
if (trades.length === 0 || (delay >= 0 && delay < 10)) {
// Update now if this is the first time for this address/network OR within the range to start now
if (!lastCheckedBlock || (delay >= 0 && delay < 10)) {
updateTrades()
}

Expand All @@ -106,7 +106,7 @@ export function useTrades(): Trade[] {
cancelled = true
if (intervalId) clearInterval(intervalId)
}
}, [userAddress, networkId, lastCheckedBlock, dispatch, trades, orders])
}, [userAddress, networkId, lastCheckedBlock, dispatch, orders])

// latest first
return trades.slice(0).reverse()
Expand Down

0 comments on commit 1205bdc

Please sign in to comment.