diff --git a/frontend/src/components/notifications/NotificationToaster.tsx b/frontend/src/components/notifications/NotificationToaster.tsx index 53f6d0c..89f2ac6 100644 --- a/frontend/src/components/notifications/NotificationToaster.tsx +++ b/frontend/src/components/notifications/NotificationToaster.tsx @@ -36,9 +36,15 @@ export default function NotificationToaster() { await respondRef.current({ requestId, action }); toast.dismiss(loadingId); toast.success(action === 'accept' ? 'Connection accepted' : 'Request declined'); - } catch (err) { + } catch (err: any) { toast.dismiss(loadingId); - toast.error(getErrorMessage(err, 'Failed to respond to request')); + // 409 means the request was already resolved (e.g. accepted via notification center) + const status = err?.response?.status; + if (status === 409) { + toast.success(action === 'accept' ? 'Connection already accepted' : 'Request already resolved'); + } else { + toast.error(getErrorMessage(err, 'Failed to respond to request')); + } } finally { respondingRef.current.delete(requestId); } diff --git a/frontend/src/components/notifications/NotificationsPage.tsx b/frontend/src/components/notifications/NotificationsPage.tsx index 2ab5f9c..6ea9c09 100644 --- a/frontend/src/components/notifications/NotificationsPage.tsx +++ b/frontend/src/components/notifications/NotificationsPage.tsx @@ -31,7 +31,7 @@ export default function NotificationsPage() { deleteNotification, } = useNotifications(); - const { incomingRequests, respond, isResponding } = useConnections(); + const { incomingRequests, respond, isResponding, isLoadingIncoming } = useConnections(); const queryClient = useQueryClient(); const navigate = useNavigate(); const [filter, setFilter] = useState('all'); @@ -93,7 +93,13 @@ export default function NotificationsPage() { } toast.success(action === 'accept' ? 'Connection accepted' : 'Request declined'); } catch (err) { - toast.error(getErrorMessage(err, 'Failed to respond')); + // 409 means the request was already resolved (e.g. accepted via toast) + const status = (err as any)?.response?.status; + if (status === 409) { + toast.success(action === 'accept' ? 'Connection already accepted' : 'Request already resolved'); + } else { + toast.error(getErrorMessage(err, 'Failed to respond')); + } } }; @@ -218,22 +224,23 @@ export default function NotificationsPage() { {/* Connection request actions (inline) */} {notification.type === 'connection_request' && notification.source_id && - pendingRequestIds.has(notification.source_id) && ( + !notification.is_read && + (isLoadingIncoming || pendingRequestIds.has(notification.source_id)) && (