Refactor NotificationContext to simplify notification fetching logic by removing redundant useEffect. Update condition checks for authenticated and notificationCenterVisible to use strict equality.
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
This commit is contained in:
parent
52fd0ebd63
commit
04d26600fd
@ -113,17 +113,11 @@ const NotificationProvider = ({ children }) => {
|
|||||||
const unreadCount = notifications.filter((n) => !n.read).length
|
const unreadCount = notifications.filter((n) => !n.read).length
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (authenticated && notificationCenterVisible) {
|
if (authenticated == true && notificationCenterVisible == true) {
|
||||||
fetchNotifications()
|
fetchNotifications()
|
||||||
}
|
}
|
||||||
}, [authenticated, notificationCenterVisible, fetchNotifications])
|
}, [authenticated, notificationCenterVisible, fetchNotifications])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (authenticated) {
|
|
||||||
fetchNotifications()
|
|
||||||
}
|
|
||||||
}, [authenticated, fetchNotifications])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setNotificationCenterVisible(false)
|
setNotificationCenterVisible(false)
|
||||||
}, [location.pathname])
|
}, [location.pathname])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user