mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
* Move setProject out of withAuth * Update apps/studio/hooks/misc/useStore.tsx Co-authored-by: Alaister Young <alaister@users.noreply.github.com> --------- Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
This commit is contained in:
1 parent
2a4e4442b0
commit
d877de2a4c
2 files changed
+9
-8
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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} />
|
||||
|
||||
Reference in new issue
Block a user