The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Pages should load when data is already initialized, and not everytime its loading
Joshen Lime05ae965cd67
diff --git a/studio/components/layouts/AuthLayout/AuthLayout.tsx b/studio/components/layouts/AuthLayout/AuthLayout.tsxindex f77c36cf106..3feb7ba12a2 100644--- a/studio/components/layouts/AuthLayout/AuthLayout.tsx+++ b/studio/components/layouts/AuthLayout/AuthLayout.tsx@@ -15,16 +15,15 @@ interface Props {const AuthLayout: FC<Props> = ({ title, children }) => {const { ui, meta } = useStore()- const { isLoading, error } = meta.tables+ const { isInitialized, isLoading, error } = meta.tablesconst projectRef = ui.selectedProject?.ref ?? 'default'const router = useRouter()const page = router.pathname.split('/')[4]- const [loaded, setLoaded] = useState<boolean>(false)+ const [loaded, setLoaded] = useState<boolean>(isInitialized)useEffect(() => {- // I think we should just shift the loading of things into the page levelmeta.tables.load()}, [])diff --git a/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx b/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsxindex 3cd4ccddd72..50f018fc642 100644--- a/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx+++ b/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx@@ -15,13 +15,13 @@ interface Props {const DatabaseLayout: FC<Props> = ({ title, children }) => {const { meta, ui } = useStore()- const { isLoading, error } = meta.tables+ const { isInitialized, isLoading, error } = meta.tablesconst project = ui.selectedProjectconst router = useRouter()const page = router.pathname.split('/')[4]- const [loaded, setLoaded] = useState<boolean>(false)+ const [loaded, setLoaded] = useState<boolean>(isInitialized)useEffect(() => {// Eventually should only load the required stores based on the pagesdiff --git a/studio/components/layouts/SQLEditorLayout/SQLEditorLayout.tsx b/studio/components/layouts/SQLEditorLayout/SQLEditorLayout.tsxindex 4dccc85a0f3..9de4c3bdbef 100644--- a/studio/components/layouts/SQLEditorLayout/SQLEditorLayout.tsx+++ b/studio/components/layouts/SQLEditorLayout/SQLEditorLayout.tsx@@ -14,9 +14,9 @@ interface Props {const SQLEditorLayout: FC<Props> = ({ title, children }) => {const { content } = useStore()- const { isLoading, error } = content+ const { isInitialized, isLoading, error } = content- const [loaded, setLoaded] = useState(false)+ const [loaded, setLoaded] = useState(isInitialized)useEffect(() => {content.load()diff --git a/studio/components/layouts/SQLEditorLayout/SQLEditorMenuOld.tsx b/studio/components/layouts/SQLEditorLayout/SQLEditorMenuOld.tsxindex f5b49b47f43..3ac56b42485 100644--- a/studio/components/layouts/SQLEditorLayout/SQLEditorMenuOld.tsx+++ b/studio/components/layouts/SQLEditorLayout/SQLEditorMenuOld.tsx@@ -227,7 +227,7 @@ const SideBarContent = observer(() => {})}</div>)}- <Loading active={contentStore.isLoading}>+ <Loading active={contentStore.isInitialized}><div className="px-3 space-y-6">{favouriteTabs.length >= 1 && (<div className="editor-product-menu">diff --git a/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx b/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsxindex 365fba2793a..3ea80225b6c 100644--- a/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx+++ b/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx@@ -28,9 +28,9 @@ const TableEditorLayout: FC<Props> = ({children,}) => {const { meta } = useStore()- const { isLoading, error } = meta.tables+ const { isInitialized, isLoading, error } = meta.tables- const [loaded, setLoaded] = useState<boolean>(false)+ const [loaded, setLoaded] = useState<boolean>(isInitialized)useEffect(() => {meta.schemas.load()diff --git a/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx b/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsxindex b174bb2afd1..4495125d1fe 100644--- a/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx+++ b/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx@@ -97,7 +97,7 @@ const TableEditorMenu: FC<Props> = ({<div className="my-6 flex flex-col flex-grow">{/* Schema selection dropdown */}<div className="mx-4">- {meta.schemas.isLoading ? (+ {!meta.schemas.isInitialized ? (<div className="h-[30px] border border-gray-500 px-3 rounded flex items-center space-x-3"><IconLoader className="animate-spin" size={14} /><Typography.Text small>Loading schemas...</Typography.Text>diff --git a/studio/stores/content/ProjectContentStore.ts b/studio/stores/content/ProjectContentStore.tsindex 4ad1f5f6da6..2952aaa42a0 100644--- a/studio/stores/content/ProjectContentStore.ts+++ b/studio/stores/content/ProjectContentStore.ts@@ -11,6 +11,7 @@ import { API_URL } from 'lib/constants'export interface IProjectContentStore {isLoading: boolean+ isInitialized: booleanerror: anyload: () => void@@ -47,6 +48,10 @@ export default class ProjectContentStore implements IProjectContentStore {return this.state === this.STATES.INITIAL || this.state === this.STATES.LOADING}+ get isInitialized() {+ return this.state !== this.STATES.INITIAL+ }+async fetchData() {const headers = {'Content-Type': 'application/json',