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 <noreply@anthropic.com>
This commit is contained in:
parent
f854987f53
commit
5828bbf8e2
@ -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],
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user