The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Revert "chore: clean up withAuth"
phamhieu1254c60b52c7
diff --git a/studio/hooks/misc/withAuth.tsx b/studio/hooks/misc/withAuth.tsxindex 11d4b57e5ee..1ebbe3ef816 100644--- a/studio/hooks/misc/withAuth.tsx+++ b/studio/hooks/misc/withAuth.tsx@@ -1,8 +1,10 @@import { useProfile, useStore } from 'hooks'-import { ComponentType, useEffect } from 'react'+import { ComponentType, useEffect, useState } from 'react'+import { flatten, isUndefined } from 'lodash'import { NextRouter, useRouter } from 'next/router'import { IS_PLATFORM } from 'lib/constants'import Connecting from 'components/ui/Loading'+import { Project } from 'types'const PLATFORM_ONLY_PAGES = ['storage', 'reports', 'settings']@@ -16,6 +18,7 @@ export function withAuth(return (props: any) => {const router = useRouter()const rootStore = useStore()+ const [isConnecting, setConnecting] = useState(true)const { ref, slug } = router.queryconst { app, ui } = rootStore@@ -32,7 +35,6 @@ export function withAuth(const isRedirecting =isAccessingBlockedPage ||checkRedirectTo(isLoading, router, profile, redirectTo, redirectIfFound)- const isConnecting = !isLoading && !isRedirecting && router.isReady ? false : trueuseEffect(() => {// this should run before redirecting@@ -64,6 +66,12 @@ export function withAuth(}}, [isLoading, router.isReady, ref, slug])+ useEffect(() => {+ if (!isLoading && !isRedirecting && router.isReady) {+ setConnecting(false)+ }+ }, [isLoading, isRedirecting, router.isReady])+if (isConnecting) return <Connecting />return <WrappedComponent {...props} />@@ -71,7 +79,7 @@ export function withAuth(}function defaultRedirectTo(ref: string | string[] | undefined) {- return IS_PLATFORM ? '/' : ref !== undefined ? `/project/${ref}` : '/'+ return IS_PLATFORM ? '/' : !isUndefined(ref) ? `/project/${ref}` : '/'}function checkRedirectTo(