From 7f547c90c256684a6b1439df855d9920880c1431 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Tue, 25 Feb 2025 20:02:27 -0500 Subject: [PATCH] feature/IO-3096-GlobalNotifications - Checkpoint --- .../notification-center.container.jsx | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/client/src/components/notification-center/notification-center.container.jsx b/client/src/components/notification-center/notification-center.container.jsx index 9f7a1a05c..9bdc42114 100644 --- a/client/src/components/notification-center/notification-center.container.jsx +++ b/client/src/components/notification-center/notification-center.container.jsx @@ -32,9 +32,6 @@ export function NotificationCenterContainer({ visible, onClose, bodyshop }) { setError(err.message); console.error("GET_NOTIFICATIONS error:", err); setTimeout(() => refetch(), 2000); - }, - onCompleted: (data) => { - console.log("GET_NOTIFICATIONS completed:", data?.notifications); } }); @@ -91,7 +88,6 @@ export function NotificationCenterContainer({ visible, onClose, bodyshop }) { }); useEffect(() => { - console.log("Data changed:", data); if (data?.notifications) { const processedNotifications = data.notifications .map((notif) => { @@ -120,15 +116,11 @@ export function NotificationCenterContainer({ visible, onClose, bodyshop }) { read: notif.read, __typename: notif.__typename }; - console.log("Processed notification with RO:", processed); return processed; }) .sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); - console.log("Setting notifications with RO:", processedNotifications); setNotifications(processedNotifications); setError(null); - } else { - console.log("No notifications in data:", data); } }, [data]); @@ -138,18 +130,12 @@ export function NotificationCenterContainer({ visible, onClose, bodyshop }) { } }, [queryError, mutationError]); - useEffect(() => { - console.log("Notifications state updated:", notifications); - }, [notifications]); - const loadMore = useCallback(() => { if (!loading && data?.notifications.length) { - console.log("Loading more notifications, current length:", data.notifications.length); fetchMore({ variables: { offset: data.notifications.length }, updateQuery: (prev, { fetchMoreResult }) => { if (!fetchMoreResult) return prev; - console.log("Fetched more:", fetchMoreResult.notifications); return { notifications: [...prev.notifications, ...fetchMoreResult.notifications] }; @@ -163,11 +149,9 @@ export function NotificationCenterContainer({ visible, onClose, bodyshop }) { const handleToggleUnreadOnly = (value) => { setShowUnreadOnly(value); - console.log("Toggled showUnreadOnly:", value); }; const handleMarkAllRead = () => { - console.log("Marking all notifications as read"); markAllReadMutation() .then(() => { const timestamp = new Date().toISOString(); @@ -175,20 +159,16 @@ export function NotificationCenterContainer({ visible, onClose, bodyshop }) { const updatedNotifications = prev.map((notif) => notif.read === null ? { ...notif, read: timestamp } : notif ); - console.log("Updated notifications after mark all read:", updatedNotifications); return [...updatedNotifications]; }); }) .catch((e) => console.error(`Error marking all notifications read: ${e?.message || ""}`)); }; + // TODO Tinker useEffect(() => { if (visible && !isConnected) { - console.log("Notification Center opened, socket disconnected, refetching..."); refetch(); - } else if (visible && isConnected) { - console.log("Notification Center opened, socket connected, relying on cache..."); - refetch(); // Ensure fresh data even with socket } }, [visible, isConnected, refetch]);