Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Address comments

Joshen Limb1a2d950057b
diff --git a/studio/components/layouts/ProjectLayout/BuildingState.tsx b/studio/components/layouts/ProjectLayout/BuildingState.tsx
index 59e6f8f0b68..42418ba43ab 100644
--- a/studio/components/layouts/ProjectLayout/BuildingState.tsx
+++ b/studio/components/layouts/ProjectLayout/BuildingState.tsx
@@ -11,12 +11,15 @@ import { invalidateProjectsQuery } from 'data/projects/projects-query'
import { getWithTimeout } from 'lib/common/fetch'
import { API_URL, PROJECT_STATUS } from 'lib/constants'
import { Project } from 'types'
+import { invalidateProjectDetailsQuery } from 'data/projects/project-detail-query'
+import { useParams } from 'common'
export interface BuildingStateProps {
project: Project
}
const BuildingState = ({ project }: BuildingStateProps) => {
+ const { ref } = useParams()
const queryClient = useQueryClient()
const checkServerInterval = useRef<number>()
@@ -31,6 +34,7 @@ const BuildingState = ({ project }: BuildingStateProps) => {
const { status } = projectStatus
if (status === PROJECT_STATUS.ACTIVE_HEALTHY) {
clearInterval(checkServerInterval.current)
+ if (ref) await invalidateProjectDetailsQuery(queryClient, ref)
await invalidateProjectsQuery(queryClient)
}
}
diff --git a/studio/components/layouts/ProjectLayout/PausingState.tsx b/studio/components/layouts/ProjectLayout/PausingState.tsx
index d802248c3de..e2cce40abce 100644
--- a/studio/components/layouts/ProjectLayout/PausingState.tsx
+++ b/studio/components/layouts/ProjectLayout/PausingState.tsx
@@ -7,6 +7,7 @@ import { invalidateProjectsQuery } from 'data/projects/projects-query'
import { PROJECT_STATUS } from 'lib/constants'
import { Project } from 'types'
import { useEffect, useState } from 'react'
+import { invalidateProjectDetailsQuery } from 'data/projects/project-detail-query'
export interface PausingStateProps {
project: Project
@@ -26,6 +27,7 @@ const PausingState = ({ project }: PausingStateProps) => {
},
onSuccess: async (res) => {
if (res.status === PROJECT_STATUS.INACTIVE) {
+ if (ref) await invalidateProjectDetailsQuery(queryClient, ref)
await invalidateProjectsQuery(queryClient)
}
},
diff --git a/studio/data/projects/project-detail-query.ts b/studio/data/projects/project-detail-query.ts
index d6d6e195045..4d7408cf4e5 100644
--- a/studio/data/projects/project-detail-query.ts
+++ b/studio/data/projects/project-detail-query.ts
@@ -1,4 +1,4 @@
-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'
+import { QueryClient, useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'
import { useCallback } from 'react'
import { get, isResponseOk } from 'lib/common/fetch'
@@ -33,14 +33,6 @@ export const useProjectDetailQuery = <TData = ProjectDetailData>(
}
)
-export const useProjectDetailPrefetch = ({ ref }: ProjectDetailVariables) => {
- const client = useQueryClient()
-
- return useCallback(() => {
- if (ref) {
- client.prefetchQuery(projectKeys.detail(ref), ({ signal }) =>
- getProjectDetail({ ref }, signal)
- )
- }
- }, [ref])
+export function invalidateProjectDetailsQuery(client: QueryClient, ref: string) {
+ return client.invalidateQueries(projectKeys.detail(ref))
}