Skip to content

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

Fix is initialized logic in postgresmeta interace

Joshen Limd59168190132
diff --git a/studio/pages/projects.tsx b/studio/pages/projects.tsx
index c3da53796bb..c67987910e6 100644
--- a/studio/pages/projects.tsx
+++ b/studio/pages/projects.tsx
@@ -10,6 +10,11 @@ import { NextPageWithLayout } from 'types'
const ProjectsPage: NextPageWithLayout = () => {
const { app } = useStore()
+ console.log({
+ isInitialized: app.organizations.isInitialized,
+ isLoading: app.organizations.isLoading,
+ })
+
return (
<>
{!app.organizations.isInitialized ? (
diff --git a/studio/stores/common/PostgresMetaInterface.ts b/studio/stores/common/PostgresMetaInterface.ts
index bd51fd319d5..d73b33ed6a3 100644
--- a/studio/stores/common/PostgresMetaInterface.ts
+++ b/studio/stores/common/PostgresMetaInterface.ts
@@ -47,6 +47,7 @@ export default class PostgresMetaInterface<T> implements IPostgresMetaInterface<
state = this.STATES.INITIAL
data: { [key in DataKeys]: T } = {}
headers: any = {}
+ isInitialized: boolean = false
constructor(
rootStore: IRootStore,
@@ -90,10 +91,6 @@ export default class PostgresMetaInterface<T> implements IPostgresMetaInterface<
return this.state === this.STATES.INITIAL || this.state === this.STATES.LOADING
}
- get isInitialized() {
- return this.state === this.STATES.LOADED || this.state === this.STATES.ERROR
- }
-
async fetchData() {
const headers = { 'Content-Type': 'application/json', ...this.headers }
const response = await get<T[]>(this.url, { headers })
@@ -109,6 +106,7 @@ export default class PostgresMetaInterface<T> implements IPostgresMetaInterface<
this.setError(null)
this.setState(LOADING)
await this.fetchData()
+ if (!this.isInitialized) this.isInitialized = true
this.setState(LOADED)
} catch (e: any) {
console.error('Load error message', e.message)