The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
reset react-query on auth change
Alaister Young0505756b0dc8
diff --git a/studio/components/interfaces/SignIn/SignInForm.tsx b/studio/components/interfaces/SignIn/SignInForm.tsxindex ea8a82a4e55..d9adb6e4b6a 100644--- a/studio/components/interfaces/SignIn/SignInForm.tsx+++ b/studio/components/interfaces/SignIn/SignInForm.tsx@@ -1,10 +1,10 @@import HCaptcha from '@hcaptcha/react-hcaptcha'+import { useQueryClient } from '@tanstack/react-query'import { useStore } from 'hooks'import { usePushNext } from 'hooks/misc/useAutoAuthRedirect'import { auth } from 'lib/gotrue'import Link from 'next/link'import { useRef, useState } from 'react'-import { useSWRConfig } from 'swr'import { Button, Form, Input } from 'ui'import { object, string } from 'yup'@@ -16,7 +16,7 @@ const signInSchema = object({const SignInForm = () => {const { ui } = useStore()const pushNext = usePushNext()- const { cache } = useSWRConfig()+ const queryClient = useQueryClient()const [captchaToken, setCaptchaToken] = useState<string | null>(null)const captchaRef = useRef<HCaptcha>(null)@@ -46,9 +46,7 @@ const SignInForm = () => {message: `Signed in successfully!`,})- // .clear() does actually exist on the cache object, but it's not in the types 🤦🏻- // @ts-ignore- cache.clear()+ await queryClient.resetQueries()await pushNext()} else {@@ -105,7 +103,7 @@ const SignInForm = () => {{/* positioned using absolute instead of labelOptional prop so tabbing between inputs works smoothly */}<Link href="/forgot-password">- <a className="text-scale-900 text-sm absolute top-0 right-0">Forgot Password?</a>+ <a className="absolute top-0 right-0 text-sm text-scale-900">Forgot Password?</a></Link></div>diff --git a/studio/components/interfaces/SignIn/SignInSSOForm.tsx b/studio/components/interfaces/SignIn/SignInSSOForm.tsxindex dbf67ccb353..9ca0c9b1786 100644--- a/studio/components/interfaces/SignIn/SignInSSOForm.tsx+++ b/studio/components/interfaces/SignIn/SignInSSOForm.tsx@@ -1,8 +1,8 @@import HCaptcha from '@hcaptcha/react-hcaptcha'+import { useQueryClient } from '@tanstack/react-query'import { useStore } from 'hooks'import { auth } from 'lib/gotrue'import { useRef, useState } from 'react'-import { useSWRConfig } from 'swr'import { Button, Form, Input } from 'ui'import { object, string } from 'yup'@@ -12,12 +12,12 @@ const signInSchema = object({const SignInSSOForm = () => {const { ui } = useStore()- const { cache } = useSWRConfig()+ const queryClient = useQueryClient()const [captchaToken, setCaptchaToken] = useState<string | null>(null)const captchaRef = useRef<HCaptcha>(null)- const onSignIn = async ({ email, password }: { email: string; password: string }) => {+ const onSignIn = async ({ email }: { email: string }) => {const toastId = ui.setNotification({category: 'loading',message: `Signing in...`,@@ -35,9 +35,7 @@ const SignInSSOForm = () => {})if (!error) {- // .clear() does actually exist on the cache object, but it's not in the types 🤦🏻- // @ts-ignore- cache.clear()+ await queryClient.resetQueries()if (data) {// redirect to SSO identity provider pagediff --git a/studio/components/layouts/AccountLayout/AccountLayout.tsx b/studio/components/layouts/AccountLayout/AccountLayout.tsxindex 76cfacfab2e..bcf23937404 100644--- a/studio/components/layouts/AccountLayout/AccountLayout.tsx+++ b/studio/components/layouts/AccountLayout/AccountLayout.tsx@@ -5,9 +5,10 @@ import { observer } from 'mobx-react-lite'import { auth, STORAGE_KEY } from 'lib/gotrue'import { useStore, withAuth, useFlag } from 'hooks'-import { API_URL, IS_PLATFORM } from 'lib/constants'+import { IS_PLATFORM } from 'lib/constants'import WithSidebar from './WithSidebar'import { SidebarSection } from './AccountLayout.types'+import { useQueryClient } from '@tanstack/react-query'interface Props {title: string@@ -21,6 +22,7 @@ interface Props {const AccountLayout: FC<Props> = ({ children, title, breadcrumbs }) => {const router = useRouter()const { app, ui } = useStore()+ const queryClient = useQueryClient()const ongoingIncident = useFlag('ongoingIncident')const maxHeight = ongoingIncident ? 'calc(100vh - 44px)' : '100vh'@@ -28,7 +30,8 @@ const AccountLayout: FC<Props> = ({ children, title, breadcrumbs }) => {const onClickLogout = async () => {await auth.signOut()localStorage.removeItem(STORAGE_KEY)- window.location.href = '/sign-in'+ await router.push('/sign-in')+ await queryClient.resetQueries()}const organizationsLinks = app.organizationsdiff --git a/studio/components/layouts/SignInLayout/SignInLayout.tsx b/studio/components/layouts/SignInLayout/SignInLayout.tsxindex 3bc77388456..a9a88f48348 100644--- a/studio/components/layouts/SignInLayout/SignInLayout.tsx+++ b/studio/components/layouts/SignInLayout/SignInLayout.tsx@@ -1,3 +1,4 @@+import { useQueryClient } from '@tanstack/react-query'import { useStore } from 'hooks'import { usePushNext } from 'hooks/misc/useAutoAuthRedirect'import { IS_PLATFORM } from 'lib/constants'@@ -8,7 +9,6 @@ import Image from 'next/image'import Link from 'next/link'import { PropsWithChildren, useEffect, useState } from 'react'import { tweets } from 'shared-data'-import { useSWRConfig } from 'swr'import { Button, IconFileText } from 'ui'type SignInLayoutProps = {@@ -27,7 +27,7 @@ const SignInLayout = ({}: PropsWithChildren<SignInLayoutProps>) => {const pushNext = usePushNext()const { ui } = useStore()- const { cache } = useSWRConfig()+ const queryClient = useQueryClient()const { theme } = uiuseEffect(() => {@@ -54,9 +54,7 @@ const SignInLayout = ({} = await auth.getSession()if (session) {- // .clear() does actually exist on the cache object, but it's not in the types 🤦🏻- // @ts-ignore- cache.clear()+ await queryClient.resetQueries()await pushNext()}