Skip to content

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

Move setProject out of withAuth so self-hosted still gets project ref #19046 (#19049)

Terry Suttond877de2a4cb2
diff --git a/apps/studio/hooks/misc/useStore.tsx b/apps/studio/hooks/misc/useStore.tsx
index 191e6ccad57..be8ae8c5048 100644
--- a/apps/studio/hooks/misc/useStore.tsx
+++ b/apps/studio/hooks/misc/useStore.tsx
@@ -4,6 +4,7 @@ import toast from 'react-hot-toast'
import SparkBar from 'components/ui/SparkBar'
import { IRootStore } from 'stores'
+import { useSelectedProject } from './useSelectedProject'
const StoreContext = createContext<IRootStore>(undefined!)
@@ -22,6 +23,13 @@ interface StoreProvider {
export const StoreProvider = ({ children, rootStore }: PropsWithChildren<StoreProvider>) => {
const { ui } = rootStore
+ const selectedProject = useSelectedProject()
+ useEffect(() => {
+ if (selectedProject) {
+ rootStore.setProject(selectedProject)
+ }
+ }, [selectedProject])
+
useEffect(() => {
autorun(() => {
if (ui.notification) {
diff --git a/apps/studio/hooks/misc/withAuth.tsx b/apps/studio/hooks/misc/withAuth.tsx
index 4b345844e01..868d96b460d 100644
--- a/apps/studio/hooks/misc/withAuth.tsx
+++ b/apps/studio/hooks/misc/withAuth.tsx
@@ -3,7 +3,7 @@ import { ComponentType, useEffect } from 'react'
import { usePermissionsQuery } from 'data/permissions/permissions-query'
import { useAuthenticatorAssuranceLevelQuery } from 'data/profile/mfa-authenticator-assurance-level-query'
-import { useSelectedProject, useStore } from 'hooks'
+import { useStore } from 'hooks'
import { useAuth } from 'lib/auth'
import { IS_PLATFORM } from 'lib/constants'
import { NextPageWithLayout, isNextPageWithLayout } from 'types'
@@ -74,13 +74,6 @@ export function withAuth<T>(
}
}, [session, isLoading, router, aalData, isFinishedLoading, isLoggedIn])
- const selectedProject = useSelectedProject()
- useEffect(() => {
- if (selectedProject) {
- rootStore.setProject(selectedProject)
- }
- }, [selectedProject])
-
const InnerComponent = WrappedComponent as any
return <InnerComponent {...props} />