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 }