Skip to content

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

fix: always set project details (#21038)

Alaister Young0a470bc40bae
diff --git a/apps/studio/hooks/misc/useSelectedProject.ts b/apps/studio/hooks/misc/useSelectedProject.ts
index be6c8035fb9..e6c2fe6e086 100644
--- a/apps/studio/hooks/misc/useSelectedProject.ts
+++ b/apps/studio/hooks/misc/useSelectedProject.ts
@@ -7,8 +7,10 @@ export function useSelectedProject() {
const { ref } = useParams()
const { data } = useProjectDetailQuery({ ref })
- if (data) return { ...data, parentRef: data?.parent_project_ref ?? data?.ref ?? undefined }
- return data
+ return useMemo(
+ () => data && { ...data, parentRef: data?.parent_project_ref ?? data?.ref },
+ [data]
+ )
}
export function useProjectByRef(ref?: string) {
diff --git a/apps/studio/stores/RootStore.ts b/apps/studio/stores/RootStore.ts
index dfa48a70ff4..c428eec6a4b 100644
--- a/apps/studio/stores/RootStore.ts
+++ b/apps/studio/stores/RootStore.ts
@@ -14,16 +14,12 @@ export interface IRootStore {
ui: IUiStore
meta: IMetaStore
- selectedProjectRef?: string
-
setProject: (project: Project) => void
}
export class RootStore implements IRootStore {
ui: IUiStore
meta: IMetaStore
- selectedProjectRef: string | undefined
-
constructor() {
this.ui = new UiStore(this)
this.meta = new MetaStore(this, { projectRef: '', connectionString: '' })
@@ -35,16 +31,8 @@ export class RootStore implements IRootStore {
* This method will also trigger project detail loading when it's not available
*/
setProject(project: Project) {
- if (this.selectedProjectRef === project.ref) return
-
- // reset ui projectRef in case of switching projects
- // this will show the loading screen instead of showing the previous project
- this.ui.setProjectRef(undefined)
-
this.meta.setProjectDetails(project)
// ui set must come last
this.ui.setProjectRef(project.ref)
-
- this.selectedProjectRef = project.ref
}
}