Skip to content

Commit

Permalink
fix: farm spam API (#2262)
Browse files Browse the repository at this point in the history
  • Loading branch information
namgold authored Sep 22, 2023
1 parent bfc1356 commit fe502ba
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/state/farms/elasticv2/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ export default function ElasticFarmV2Updater({ interval = true }: { interval?: b
if (isEnableKNProtocol) return knProtocolError
return subgraphError
}, [isEnableKNProtocol, subgraphError, knProtocolError])
const isLoadingElasticFarm = useRef(elasticFarm.loading)
isLoadingElasticFarm.current = elasticFarm.loading

useEffect(() => {
if (isEVM && !elasticFarm?.farms && !elasticFarm?.loading) {
if (isEVM && !elasticFarm?.farms && !isLoadingElasticFarm.current) {
dispatch(setLoading({ chainId, loading: true }))
if (isEnableKNProtocol) {
getElasticFarmV2FromKnProtocol(chainId).finally(() => {
Expand All @@ -149,7 +151,15 @@ export default function ElasticFarmV2Updater({ interval = true }: { interval?: b
dispatch(setLoading({ chainId, loading: false }))
})
}
}, [isEVM, chainId, dispatch, getElasticFarmV2, elasticFarm, getElasticFarmV2FromKnProtocol, isEnableKNProtocol])
}, [
isEVM,
chainId,
dispatch,
getElasticFarmV2,
elasticFarm?.farms,
getElasticFarmV2FromKnProtocol,
isEnableKNProtocol,
])

useEffect(() => {
const i = interval
Expand Down

0 comments on commit fe502ba

Please sign in to comment.