From fe502baeb67c9f5f17cd2270f67313c921a2d0f1 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Fri, 22 Sep 2023 12:02:42 +0700 Subject: [PATCH] fix: farm spam API (#2262) --- src/state/farms/elasticv2/updater.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/state/farms/elasticv2/updater.tsx b/src/state/farms/elasticv2/updater.tsx index 643de26358..f8b893e5ca 100644 --- a/src/state/farms/elasticv2/updater.tsx +++ b/src/state/farms/elasticv2/updater.tsx @@ -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(() => { @@ -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