Skip to content

Commit

Permalink
switch to prod
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Sep 26, 2023
1 parent a66181c commit 93f1fbb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/state/farms/elastic/updaters/v1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ const FarmUpdaterV1: React.FC<CommonProps> = ({ 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 {
Expand Down Expand Up @@ -266,7 +267,7 @@ const FarmUpdaterV1: React.FC<CommonProps> = ({ interval }) => {
})
dispatch(setFarms({ chainId, farms: formattedData }))
}
}, [data, dispatch, chainId, elasticFarm])
}, [data, dispatch, chainId, hasFarm])

return null
}
Expand Down
23 changes: 15 additions & 8 deletions src/state/farms/elasticv2/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 93f1fbb

Please sign in to comment.