From 2227dcc9a0715f34e7ece9b97d4929ffb36c94bd Mon Sep 17 00:00:00 2001 From: WRadoslaw <92513933+WRadoslaw@users.noreply.github.com> Date: Wed, 27 Dec 2023 13:25:10 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=91=20Stop=20polling=20if=20notificati?= =?UTF-8?q?ons=20recipient=20is=20undefined=20(#5695)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/providers/notifications/notifications.hooks.ts | 2 ++ .../src/providers/notifications/notifications.manager.tsx | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/atlas/src/providers/notifications/notifications.hooks.ts b/packages/atlas/src/providers/notifications/notifications.hooks.ts index 782d2467ed..564b31df69 100644 --- a/packages/atlas/src/providers/notifications/notifications.hooks.ts +++ b/packages/atlas/src/providers/notifications/notifications.hooks.ts @@ -32,6 +32,7 @@ export type UseNotifications = Pick setLastSeenNotificationDate: (data: Date) => void markNotificationsAsRead: (notifications: NotificationRecord[]) => void pageInfo?: GetNotificationsConnectionQuery['notificationsConnection']['pageInfo'] + recipient: RecipientTypeWhereInput | undefined } export const useNotifications = (opts?: Pick): UseNotifications => { @@ -120,6 +121,7 @@ export const useNotifications = (opts?: Pick { - const { fetchMore, unseenNotificationsCounts } = useNotifications() + const { fetchMore, unseenNotificationsCounts, recipient } = useNotifications() useEffect(() => { const id = setInterval(() => { + if (!recipient) { + return + } + unseenNotificationsCounts.fetchMore() fetchMore({ updateQuery: (prev, { fetchMoreResult }) => { @@ -44,7 +48,7 @@ export const NotificationsManager: FC = () => { clearInterval(id) } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [fetchMore, unseenNotificationsCounts.fetchMore]) + }, [fetchMore, unseenNotificationsCounts.fetchMore, !recipient]) return null }