From 93f1fbbc307cee6d8b64628b0bcf484487a0855a Mon Sep 17 00:00:00 2001 From: viet-nv Date: Tue, 26 Sep 2023 14:22:49 +0700 Subject: [PATCH] switch to prod --- .github/workflows/pr.yaml | 2 +- src/state/farms/elastic/updaters/v1.tsx | 5 +++-- src/state/farms/elasticv2/updater.tsx | 23 +++++++++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 4fc367b68b..0b9eaa7c9a 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -114,7 +114,7 @@ jobs: VITE_TAG: ${{ needs.prepare.outputs.image_tag }} CURRENT_BRANCH: ${{ needs.prepare.outputs.current_branch }} NODE_OPTIONS: '--max_old_space_size=4096' - run: yarn build-adpr + run: yarn build-prod - name: Docker build and push uses: docker/build-push-action@v2 diff --git a/src/state/farms/elastic/updaters/v1.tsx b/src/state/farms/elastic/updaters/v1.tsx index 368cc5b883..02135e84f1 100644 --- a/src/state/farms/elastic/updaters/v1.tsx +++ b/src/state/farms/elastic/updaters/v1.tsx @@ -177,8 +177,9 @@ const FarmUpdaterV1: React.FC = ({ interval }) => { } }, [error, dispatch, chainId]) + const hasFarm = elasticFarm?.farms?.length useEffect(() => { - if (data?.farms && chainId && !elasticFarm?.farms?.length) { + if (data?.farms && chainId && !hasFarm) { // transform farm data const formattedData: ElasticFarm[] = data.farms.map((farm: SubgraphFarm) => { return { @@ -266,7 +267,7 @@ const FarmUpdaterV1: React.FC = ({ interval }) => { }) dispatch(setFarms({ chainId, farms: formattedData })) } - }, [data, dispatch, chainId, elasticFarm]) + }, [data, dispatch, chainId, hasFarm]) return null } diff --git a/src/state/farms/elasticv2/updater.tsx b/src/state/farms/elasticv2/updater.tsx index 1e780af31f..60b073ebe7 100644 --- a/src/state/farms/elasticv2/updater.tsx +++ b/src/state/farms/elasticv2/updater.tsx @@ -135,21 +135,28 @@ export default function ElasticFarmV2Updater({ interval = true }: { interval?: b }, [isEnableKNProtocol, subgraphError, knProtocolError]) useEffect(() => { - const getFarm = (withLoading = false) => { + const getFarm = (chainId: number, withLoading = false) => { if (withLoading) dispatch(setLoading({ chainId, loading: true })) if (isEnableKNProtocol) getElasticFarmV2FromKnProtocol(chainId).finally(() => { - if (withLoading) dispatch(setLoading({ chainId, loading: false })) + dispatch(setLoading({ chainId, loading: false })) }) - else + else { getElasticFarmV2().finally(() => { - if (withLoading) dispatch(setLoading({ chainId, loading: false })) + dispatch(setLoading({ chainId, loading: false })) }) + } } - dispatch(knProtocolApi.util.resetApiState()) - dispatch(setFarms({ chainId, farms: [] })) - getFarm(true) - const i = interval ? setInterval(() => getFarm(false), 10_000) : undefined + Promise.resolve(dispatch(knProtocolApi.util.resetApiState())).then(() => { + dispatch(setFarms({ chainId, farms: [] })) + getFarm(chainId, true) + }) + // for chain which is not enable kn protocol + setTimeout(() => { + dispatch(setLoading({ chainId, loading: false })) + }, 3000) + + const i = interval ? setInterval(() => getFarm(chainId, false), 10_000) : undefined return () => { i && clearInterval(i) }