Skip to content

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

Skip invalidating auth config when toggling security email notification in template editor page (#44888)

Joshen Lim71acf2231841
diff --git a/apps/studio/data/auth/auth-config-update-mutation.ts b/apps/studio/data/auth/auth-config-update-mutation.ts
index 46f37188db6..f21414a47b5 100644
--- a/apps/studio/data/auth/auth-config-update-mutation.ts
+++ b/apps/studio/data/auth/auth-config-update-mutation.ts
@@ -10,6 +10,7 @@ import type { ResponseError, UseCustomMutationOptions } from '@/types'
export type AuthConfigUpdateVariables = {
projectRef: string
config: Partial<components['schemas']['UpdateGoTrueConfigBody']>
+ skipInvalidation?: boolean
}
export async function updateAuthConfig({ projectRef, config }: AuthConfigUpdateVariables) {
@@ -41,9 +42,10 @@ export const useAuthConfigUpdateMutation = ({
return useMutation<AuthConfigUpdateData, ResponseError, AuthConfigUpdateVariables>({
mutationFn: (vars) => updateAuthConfig(vars),
async onSuccess(data, variables, context) {
- const { projectRef } = variables
+ const { projectRef, skipInvalidation = false } = variables
await Promise.all([
- queryClient.invalidateQueries({ queryKey: authKeys.authConfig(projectRef) }),
+ !skipInvalidation &&
+ queryClient.invalidateQueries({ queryKey: authKeys.authConfig(projectRef) }),
queryClient.invalidateQueries({ queryKey: lintKeys.lint(projectRef) }),
])
await queryClient.refetchQueries({
diff --git a/apps/studio/pages/project/[ref]/auth/templates/[templateId].tsx b/apps/studio/pages/project/[ref]/auth/templates/[templateId].tsx
index 47cf34ca5e4..ec1c030dcf8 100644
--- a/apps/studio/pages/project/[ref]/auth/templates/[templateId].tsx
+++ b/apps/studio/pages/project/[ref]/auth/templates/[templateId].tsx
@@ -127,9 +127,9 @@ const RedirectToTemplates = () => {
defaultValues,
})
- const onSubmit = (values: any) => {
+ const onSubmit = (values: z.infer<typeof TemplateFormSchema>) => {
if (!projectRef) return console.error('Project ref is required')
- updateAuthConfig({ projectRef: projectRef, config: { ...values } })
+ updateAuthConfig({ projectRef: projectRef, config: { ...values }, skipInvalidation: true })
}
useEffect(() => {