From 5828bbf8e214c79f40ee04cd72eedab6d12bff5d Mon Sep 17 00:00:00 2001 From: Kyle Pope Date: Wed, 4 Mar 2026 10:15:23 +0800 Subject: [PATCH] Fix toast accept showing false error when invalidations fail Separate API error handling from query invalidation in NotificationToaster's handleConnectionRespond so a failed refetch doesn't surface as "Failed to respond" after a successful accept. Co-Authored-By: Claude Opus 4.6 --- .../notifications/NotificationToaster.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/notifications/NotificationToaster.tsx b/frontend/src/components/notifications/NotificationToaster.tsx index 11597f0..9ac1f36 100644 --- a/frontend/src/components/notifications/NotificationToaster.tsx +++ b/frontend/src/components/notifications/NotificationToaster.tsx @@ -17,17 +17,17 @@ export default function NotificationToaster() { async (requestId: number, action: 'accept' | 'reject', toastId: string | number) => { try { await api.put(`/connections/requests/${requestId}/respond`, { action }); - toast.dismiss(toastId); - toast.success(action === 'accept' ? 'Connection accepted' : 'Request declined'); - await Promise.all([ - queryClient.invalidateQueries({ queryKey: ['connections'] }), - queryClient.invalidateQueries({ queryKey: ['people'] }), - queryClient.invalidateQueries({ queryKey: ['notifications'] }), - ]); } catch (err) { toast.dismiss(toastId); toast.error(getErrorMessage(err, 'Failed to respond to request')); + return; } + toast.dismiss(toastId); + toast.success(action === 'accept' ? 'Connection accepted' : 'Request declined'); + // Fire-and-forget — invalidation errors should not surface as "Failed to respond" + queryClient.invalidateQueries({ queryKey: ['connections'] }); + queryClient.invalidateQueries({ queryKey: ['people'] }); + queryClient.invalidateQueries({ queryKey: ['notifications'] }); }, [queryClient], );