Skip to content

Commit

Permalink
fix: Environment Ready Checker (#4865)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Nov 26, 2024
1 parent 94a7f49 commit 2392222
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frontend/web/components/EnvironmentReadyChecker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from 'react'
import { FC, useEffect, useState } from 'react'
import { useGetEnvironmentQuery } from 'common/services/useEnvironment'

type EnvironmentReadyCheckerType = {
Expand All @@ -13,12 +13,22 @@ const EnvironmentReadyChecker: FC<EnvironmentReadyCheckerType> = ({
children,
match,
}) => {
const [environmentCreated, setEnvironmentCreated] = useState(false)

const { data, isLoading } = useGetEnvironmentQuery(
{
id: match.params.environmentId,
},
{ pollingInterval: 1000, skip: !match.params.environmentId },
{
pollingInterval: 1000,
skip: !match.params.environmentId || environmentCreated,
},
)
useEffect(() => {
if (!!data && !data?.is_creating) {
setEnvironmentCreated(true)
}
}, [data])
if (!match?.params?.environmentId) {
return children
}
Expand Down

0 comments on commit 2392222

Please sign in to comment.