Skip to content

Commit

Permalink
Merge pull request #276 from chain4travel/fix-dac-error
Browse files Browse the repository at this point in the history
chore: Remove setTimeout from feature checks in PlatformSwitcher, Rou…  7b6156c …tesSuite, and LandingPage; add error handling in checkFeature
  • Loading branch information
Ysrbolles authored Nov 28, 2024
2 parents eac0db4 + 6fa5d23 commit 1babfee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
12 changes: 8 additions & 4 deletions src/components/PlatformSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ export default function PlatformSwitcher() {

useEffect(() => {
checkFeature()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeNetwork])

const checkFeature = async () => {
const phases = await getUpgradePhases()
const enabled = await isFeatureEnabled('DACFeature', activeNetwork?.url, phases)

setFeatureEnabled(enabled)
try {
const phases = await getUpgradePhases()
const enabled = await isFeatureEnabled('DACFeature', activeNetwork?.url, phases)
setFeatureEnabled(enabled)
} catch (error) {
setFeatureEnabled(false)
}
}

return (
Expand Down
12 changes: 8 additions & 4 deletions src/layout/RoutesSuite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ export default function RoutesSuite() {

useEffect(() => {
checkFeature()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeNetwork])

const checkFeature = async () => {
const phases = await getUpgradePhases()
const enabled = await isFeatureEnabled('DACFeature', activeNetwork?.url, phases)
setFeatureEnabled(enabled)
try {
const phases = await getUpgradePhases()
const enabled = await isFeatureEnabled('DACFeature', activeNetwork?.url, phases)
setFeatureEnabled(enabled)
} catch (error) {
setFeatureEnabled(false)
}
}

return (
<>
<Routes>
Expand Down
11 changes: 8 additions & 3 deletions src/views/landing/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ export default function LandingPage() {

useEffect(() => {
checkFeature()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeNetwork])

const checkFeature = async () => {
const phases = await getUpgradePhases()
const enabled = await isFeatureEnabled('DACFeature', activeNetwork?.url, phases)
setFeatureEnabled(enabled)
try {
const phases = await getUpgradePhases()
const enabled = await isFeatureEnabled('DACFeature', activeNetwork?.url, phases)
setFeatureEnabled(enabled)
} catch (error) {
setFeatureEnabled(false)
}
}

const handleWidgetClick = app => {
Expand Down

0 comments on commit 1babfee

Please sign in to comment.