mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-16 19:49:14 +00:00
fix(web): suppress global error toast on mutations that own their toast UX
Closes #1371. Retarget of #1385 onto dev per maintainer request. surfsense_web/lib/query-client/client.ts configures a global MutationCache.onError that shows an error toast for every failed mutation unless meta.suppressGlobalErrorToast is set. The opt-out hook existed in the consumer but had zero producers — every mutation atom that already had its own onError: toast.error(...) was double-toasting on failure. Add meta: { suppressGlobalErrorToast: true } to the 30 mutations across 9 atom files that own their own error toast: - atoms/prompts/prompts-mutation.atoms.ts (4) - atoms/invites/invites-mutation.atoms.ts (4) - atoms/chat-comments/comments-mutation.atoms.ts (4) - atoms/new-llm-config/new-llm-config-mutation.atoms.ts (4) - atoms/members/members-mutation.atoms.ts (3) - atoms/roles/roles-mutation.atoms.ts (3) - atoms/image-gen-config/image-gen-config-mutation.atoms.ts (3) - atoms/vision-llm-config/vision-llm-config-mutation.atoms.ts (3) - atoms/public-chat-snapshots/public-chat-snapshots-mutation.atoms.ts (2) Atoms intentionally left alone (no local onError, rely on global): auth, user, search-spaces, logs, documents, connectors. Local validation (against dev): pnpm biome check on the 9 touched files is clean; tsc --noEmit shows no new errors in the touched files (pre-existing errors elsewhere unrelated). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
eea2d68098
commit
bf2b4ebeb0
9 changed files with 30 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ import { cacheKeys } from "@/lib/query-client/cache-keys";
|
|||
import { queryClient } from "@/lib/query-client/client";
|
||||
|
||||
export const createCommentMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: CreateCommentRequest) => {
|
||||
return chatCommentsApiService.createComment(request);
|
||||
},
|
||||
|
|
@ -26,6 +27,7 @@ export const createCommentMutationAtom = atomWithMutation(() => ({
|
|||
}));
|
||||
|
||||
export const createReplyMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: CreateReplyRequest & { message_id: number }) => {
|
||||
return chatCommentsApiService.createReply(request);
|
||||
},
|
||||
|
|
@ -41,6 +43,7 @@ export const createReplyMutationAtom = atomWithMutation(() => ({
|
|||
}));
|
||||
|
||||
export const updateCommentMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: UpdateCommentRequest & { message_id: number }) => {
|
||||
return chatCommentsApiService.updateComment(request);
|
||||
},
|
||||
|
|
@ -56,6 +59,7 @@ export const updateCommentMutationAtom = atomWithMutation(() => ({
|
|||
}));
|
||||
|
||||
export const deleteCommentMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: DeleteCommentRequest & { message_id: number }) => {
|
||||
return chatCommentsApiService.deleteComment(request);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export const createImageGenConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["image-gen-configs", "create"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: CreateImageGenConfigRequest) => {
|
||||
return imageGenConfigApiService.createConfig(request);
|
||||
|
|
@ -45,6 +46,7 @@ export const updateImageGenConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["image-gen-configs", "update"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: UpdateImageGenConfigRequest) => {
|
||||
return imageGenConfigApiService.updateConfig(request);
|
||||
|
|
@ -72,6 +74,7 @@ export const deleteImageGenConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["image-gen-configs", "delete"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: { id: number; name: string }) => {
|
||||
return imageGenConfigApiService.deleteConfig(request.id);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { queryClient } from "@/lib/query-client/client";
|
|||
* Mutation atom for creating an invite
|
||||
*/
|
||||
export const createInviteMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: CreateInviteRequest) => {
|
||||
return invitesApiService.createInvite(request);
|
||||
},
|
||||
|
|
@ -33,6 +34,7 @@ export const createInviteMutationAtom = atomWithMutation(() => ({
|
|||
* Mutation atom for updating an invite
|
||||
*/
|
||||
export const updateInviteMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: UpdateInviteRequest) => {
|
||||
return invitesApiService.updateInvite(request);
|
||||
},
|
||||
|
|
@ -52,6 +54,7 @@ export const updateInviteMutationAtom = atomWithMutation(() => ({
|
|||
* Mutation atom for deleting an invite
|
||||
*/
|
||||
export const deleteInviteMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: DeleteInviteRequest) => {
|
||||
return invitesApiService.deleteInvite(request);
|
||||
},
|
||||
|
|
@ -71,6 +74,7 @@ export const deleteInviteMutationAtom = atomWithMutation(() => ({
|
|||
* Mutation atom for accepting an invite
|
||||
*/
|
||||
export const acceptInviteMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: AcceptInviteRequest) => {
|
||||
return invitesApiService.acceptInvite(request);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { queryClient } from "@/lib/query-client/client";
|
|||
|
||||
export const updateMemberMutationAtom = atomWithMutation(() => {
|
||||
return {
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: UpdateMembershipRequest) => {
|
||||
return membersApiService.updateMember(request);
|
||||
},
|
||||
|
|
@ -31,6 +32,7 @@ export const updateMemberMutationAtom = atomWithMutation(() => {
|
|||
|
||||
export const deleteMemberMutationAtom = atomWithMutation(() => {
|
||||
return {
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: DeleteMembershipRequest) => {
|
||||
return membersApiService.deleteMember(request);
|
||||
},
|
||||
|
|
@ -48,6 +50,7 @@ export const deleteMemberMutationAtom = atomWithMutation(() => {
|
|||
|
||||
export const leaveSearchSpaceMutationAtom = atomWithMutation(() => {
|
||||
return {
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: LeaveSearchSpaceRequest) => {
|
||||
return membersApiService.leaveSearchSpace(request);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ export const createNewLLMConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["new-llm-configs", "create"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: CreateNewLLMConfigRequest) => {
|
||||
return newLLMConfigApiService.createConfig(request);
|
||||
|
|
@ -47,6 +48,7 @@ export const updateNewLLMConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["new-llm-configs", "update"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: UpdateNewLLMConfigRequest) => {
|
||||
return newLLMConfigApiService.updateConfig(request);
|
||||
|
|
@ -74,6 +76,7 @@ export const deleteNewLLMConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["new-llm-configs", "delete"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: DeleteNewLLMConfigRequest & { name: string }) => {
|
||||
return newLLMConfigApiService.deleteConfig({ id: request.id });
|
||||
|
|
@ -105,6 +108,7 @@ export const updateLLMPreferencesMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["llm-preferences", "update"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: UpdateLLMPreferencesRequest) => {
|
||||
return newLLMConfigApiService.updateLLMPreferences(request);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { queryClient } from "@/lib/query-client/client";
|
|||
|
||||
export const createPromptMutationAtom = atomWithMutation(() => ({
|
||||
mutationKey: ["prompts", "create"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: PromptCreateRequest) => {
|
||||
return promptsApiService.create(request);
|
||||
},
|
||||
|
|
@ -25,6 +26,7 @@ export const createPromptMutationAtom = atomWithMutation(() => ({
|
|||
|
||||
export const updatePromptMutationAtom = atomWithMutation(() => ({
|
||||
mutationKey: ["prompts", "update"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async ({ id, ...data }: PromptUpdateRequest & { id: number }) => {
|
||||
return promptsApiService.update(id, data);
|
||||
},
|
||||
|
|
@ -39,6 +41,7 @@ export const updatePromptMutationAtom = atomWithMutation(() => ({
|
|||
|
||||
export const deletePromptMutationAtom = atomWithMutation(() => ({
|
||||
mutationKey: ["prompts", "delete"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (id: number) => {
|
||||
return promptsApiService.delete(id);
|
||||
},
|
||||
|
|
@ -57,6 +60,7 @@ export const deletePromptMutationAtom = atomWithMutation(() => ({
|
|||
|
||||
export const copyPromptMutationAtom = atomWithMutation(() => ({
|
||||
mutationKey: ["prompts", "copy"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (promptId: number) => {
|
||||
return promptsApiService.copy(promptId);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { cacheKeys } from "@/lib/query-client/cache-keys";
|
|||
import { queryClient } from "@/lib/query-client/client";
|
||||
|
||||
export const createPublicChatSnapshotMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: PublicChatSnapshotCreateRequest) => {
|
||||
return chatThreadsApiService.createPublicChatSnapshot(request);
|
||||
},
|
||||
|
|
@ -37,6 +38,7 @@ export const createPublicChatSnapshotMutationAtom = atomWithMutation(() => ({
|
|||
}));
|
||||
|
||||
export const deletePublicChatSnapshotMutationAtom = atomWithMutation(() => ({
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: PublicChatSnapshotDeleteRequest) => {
|
||||
return chatThreadsApiService.deletePublicChatSnapshot(request);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { queryClient } from "@/lib/query-client/client";
|
|||
|
||||
export const createRoleMutationAtom = atomWithMutation(() => {
|
||||
return {
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: CreateRoleRequest) => {
|
||||
return rolesApiService.createRole(request);
|
||||
},
|
||||
|
|
@ -31,6 +32,7 @@ export const createRoleMutationAtom = atomWithMutation(() => {
|
|||
|
||||
export const updateRoleMutationAtom = atomWithMutation(() => {
|
||||
return {
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: UpdateRoleRequest) => {
|
||||
return rolesApiService.updateRole(request);
|
||||
},
|
||||
|
|
@ -54,6 +56,7 @@ export const updateRoleMutationAtom = atomWithMutation(() => {
|
|||
|
||||
export const deleteRoleMutationAtom = atomWithMutation(() => {
|
||||
return {
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
mutationFn: async (request: DeleteRoleRequest) => {
|
||||
return rolesApiService.deleteRole(request);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export const createVisionLLMConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["vision-llm-configs", "create"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: CreateVisionLLMConfigRequest) => {
|
||||
return visionLLMConfigApiService.createConfig(request);
|
||||
|
|
@ -39,6 +40,7 @@ export const updateVisionLLMConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["vision-llm-configs", "update"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: UpdateVisionLLMConfigRequest) => {
|
||||
return visionLLMConfigApiService.updateConfig(request);
|
||||
|
|
@ -63,6 +65,7 @@ export const deleteVisionLLMConfigMutationAtom = atomWithMutation((get) => {
|
|||
|
||||
return {
|
||||
mutationKey: ["vision-llm-configs", "delete"],
|
||||
meta: { suppressGlobalErrorToast: true },
|
||||
enabled: !!searchSpaceId,
|
||||
mutationFn: async (request: { id: number; name: string }) => {
|
||||
return visionLLMConfigApiService.deleteConfig(request.id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue