diff --git a/src/components/Dashboard/context/NotificationContext.jsx b/src/components/Dashboard/context/NotificationContext.jsx index 75a24c8e..28982397 100644 --- a/src/components/Dashboard/context/NotificationContext.jsx +++ b/src/components/Dashboard/context/NotificationContext.jsx @@ -3,8 +3,7 @@ import { useState, useContext, useCallback, - useEffect, - useEffectEvent + useEffect } from 'react' import { useLocation } from 'react-router-dom' import { notification, Drawer } from 'antd' @@ -60,11 +59,6 @@ const NotificationProvider = ({ children }) => { } }, [authenticated, fetchNotificationsApi, showError]) - const onFetchNotifications = useEffectEvent(() => { - if (!authenticated || !connected) return - fetchNotifications() - }) - const markNotificationAsRead = useCallback( async (notificationId) => { try { @@ -121,15 +115,15 @@ const NotificationProvider = ({ children }) => { // Initial load / when we become authenticated and connected useEffect(() => { - onFetchNotifications() - }, [authenticated, connected]) + if (!authenticated || !connected) return + fetchNotifications() + }, [authenticated, connected, fetchNotifications]) // Refresh when the notification center opens useEffect(() => { - if (notificationCenterVisible) { - onFetchNotifications() - } - }, [notificationCenterVisible]) + if (!notificationCenterVisible || !authenticated || !connected) return + fetchNotifications() + }, [notificationCenterVisible, authenticated, connected, fetchNotifications]) useEffect(() => { setNotificationCenterVisible(false)