The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: remove ready variable cos metaStore and contentStore are not observable
phamhieu158ed791349f
diff --git a/studio/components/layouts/AuthLayout/AuthLayout.tsx b/studio/components/layouts/AuthLayout/AuthLayout.tsxindex dfde160c31b..da038f2bfa5 100644--- a/studio/components/layouts/AuthLayout/AuthLayout.tsx+++ b/studio/components/layouts/AuthLayout/AuthLayout.tsx@@ -24,10 +24,10 @@ const AuthLayout: FC<Props> = ({ title, children }) => {const [loaded, setLoaded] = useState<boolean>(isInitialized)useEffect(() => {- if (meta.ready) {+ if (ui.selectedProject) {meta.tables.load()}- }, [meta.ready])+ }, [ui.selectedProject])useEffect(() => {if (!isLoading && !loaded) {diff --git a/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx b/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsxindex df81b0d5dec..5df6936a062 100644--- a/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx+++ b/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx@@ -24,7 +24,7 @@ const DatabaseLayout: FC<Props> = ({ title, children }) => {const [loaded, setLoaded] = useState<boolean>(isInitialized)useEffect(() => {- if (meta.ready) {+ if (ui.selectedProject) {// Eventually should only load the required stores based on the pagesmeta.schemas.load()meta.tables.load()@@ -34,7 +34,7 @@ const DatabaseLayout: FC<Props> = ({ title, children }) => {meta.extensions.load()meta.publications.load()}- }, [meta.ready])+ }, [ui.selectedProject])useEffect(() => {if (!isLoading && !loaded) {diff --git a/studio/components/layouts/DocsLayout/DocsLayout.tsx b/studio/components/layouts/DocsLayout/DocsLayout.tsxindex 780080a6ec9..14a85bd5dc9 100644--- a/studio/components/layouts/DocsLayout/DocsLayout.tsx+++ b/studio/components/layouts/DocsLayout/DocsLayout.tsx@@ -12,10 +12,10 @@ function DocsLayout({ title, children }: { title: string; children: ReactElementconst { data, isLoading, error } = meta.openApiuseEffect(() => {- if (meta.ready) {+ if (ui.selectedProject) {meta.openApi.load()}- }, [meta.ready])+ }, [ui.selectedProject])if (error) {return (diff --git a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/studio/components/layouts/ProjectLayout/ProjectLayout.tsxindex 5f98cde9668..be75878a99f 100644--- a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx+++ b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx@@ -65,9 +65,8 @@ interface MenuBarWrapperProps {}const MenuBarWrapper: FC<MenuBarWrapperProps> = observer(({ isLoading, productMenu, children }) => {- const { ui, meta } = useStore()- const project = ui.selectedProject- return <>{!isLoading && productMenu && project !== undefined && meta.ready ? children : null}</>+ const { ui } = useStore()+ return <>{!isLoading && productMenu && ui.selectedProject !== undefined ? children : null}</>})interface ContentWrapperProps {@@ -75,14 +74,14 @@ interface ContentWrapperProps {}const ContentWrapper: FC<ContentWrapperProps> = observer(({ isLoading, children }) => {- const { ui, meta } = useStore()+ const { ui } = useStore()const router = useRouter()const project = ui.selectedProjectconst requiresDbConnection: boolean = router.pathname !== '/project/[ref]/settings/general'return (<>- {isLoading || project === undefined || !meta.ready ? (+ {isLoading || project === undefined ? (<Connecting />) : requiresDbConnection ? (<TestConnection project={project!}>diff --git a/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx b/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsxindex 729a0276ce2..787635589bd 100644--- a/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx+++ b/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx@@ -27,17 +27,17 @@ const TableEditorLayout: FC<Props> = ({onDuplicateTable = () => {},children,}) => {- const { meta } = useStore()+ const { meta, ui } = useStore()const { isInitialized, isLoading, error } = meta.tablesconst [loaded, setLoaded] = useState<boolean>(isInitialized)useEffect(() => {- if (meta.ready) {+ if (ui.selectedProject) {meta.schemas.load()meta.tables.load()}- }, [meta.ready])+ }, [ui.selectedProject])useEffect(() => {let cancel = falsediff --git a/studio/pages/project/[ref]/sql/index.tsx b/studio/pages/project/[ref]/sql/index.tsxindex 91bc5a5d937..21e61263935 100644--- a/studio/pages/project/[ref]/sql/index.tsx+++ b/studio/pages/project/[ref]/sql/index.tsx@@ -34,7 +34,7 @@ const PageConfig = () => {await sqlEditorStore.loadRemotePersistentData(contentStore, (user as any)?.id)}- if (ui.selectedProject == undefined || !meta.ready) {+ if (ui.selectedProject === undefined) {return <BaseLayout children={undefined} />}diff --git a/studio/stores/content/ProjectContentStore.ts b/studio/stores/content/ProjectContentStore.tsindex ec05327bc2b..4dd3e2c00ea 100644--- a/studio/stores/content/ProjectContentStore.ts+++ b/studio/stores/content/ProjectContentStore.ts@@ -10,7 +10,6 @@ import { API_URL } from 'lib/constants'// but use the one under the stores folder projectContentStore first while we transitionexport interface IProjectContentStore {- ready: booleanisLoading: booleanisInitialized: booleanerror: any@@ -22,7 +21,6 @@ export interface IProjectContentStore {}export default class ProjectContentStore implements IProjectContentStore {- ready: booleanrootStore: IRootStoreSTATES = {@@ -40,7 +38,6 @@ export default class ProjectContentStore implements IProjectContentStore {constructor(rootStore: IRootStore, options: { projectRef: string }) {const { projectRef } = options- this.ready = projectRef !== ''this.rootStore = rootStorethis.baseUrl = `${API_URL}/projects/${projectRef}/content`makeAutoObservable(this)diff --git a/studio/stores/pgmeta/MetaStore.ts b/studio/stores/pgmeta/MetaStore.tsindex 0537bb4538d..c2954314903 100644--- a/studio/stores/pgmeta/MetaStore.ts+++ b/studio/stores/pgmeta/MetaStore.ts@@ -43,7 +43,6 @@ const BATCH_SIZE = 1000const CHUNK_SIZE = 1024 * 1024 * 0.25 // 0.25MBexport interface IMetaStore {- ready: booleanexcludedSchemas: string[]openApi: IOpenApiStore@@ -115,7 +114,6 @@ export default class MetaStore implements IMetaStore {extensions: ExtensionsStorepublications: PublicationStore- ready: booleanconnectionString?: stringbaseUrl: stringqueryBaseUrl: string@@ -133,7 +131,6 @@ export default class MetaStore implements IMetaStore {constructor(rootStore: IRootStore, options: { projectRef: string; connectionString: string }) {const { projectRef, connectionString } = options- this.ready = projectRef !== ''this.rootStore = rootStorethis.baseUrl = `/api/pg-meta/${projectRef}`this.queryBaseUrl = `${API_URL}/pg-meta/${projectRef}`