@ -76,16 +59,28 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
@@ -76,16 +59,28 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
active
])
// Defer so we don't trigger state updates during the same commit as consumer renders (avoids "Cannot update NotificationList while rendering NotificationProvider")
useEffect(()=>{
setNewNotifications([])
updateNotificationsSeenAt(!active)
},[active])
lett2: ReturnType<typeofsetTimeout>|null=null
constt=setTimeout(()=>{
setNewNotifications([])
t2=setTimeout(()=>{
updateNotificationsSeenAt(!active)
},0)
},0)
return()=>{
clearTimeout(t)
if(t2!==null)clearTimeout(t2)
}
},[active,updateNotificationsSeenAt])
useEffect(()=>{
if(!pubkey)return
setNewNotifications([])
setReadNotificationIdSet(newSet())
constdeferredReset=setTimeout(()=>{
setNewNotifications([])
setReadNotificationIdSet(newSet())
},0)
// Track if component is mounted
constisMountedRef={current: true}
@ -262,6 +257,7 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
@@ -262,6 +257,7 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
// Cleanup function
return()=>{
clearTimeout(deferredReset)
isMountedRef.current=false
if(subCloserRef.current){
subCloserRef.current.close()
@ -322,7 +318,7 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
@@ -322,7 +318,7 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
}
},[filteredNewNotifications])
constgetNotificationsSeenAt=()=>{
constgetNotificationsSeenAt=useCallback(()=>{
if(notificationsSeenAt>=0){
returnnotificationsSeenAt
}
@ -330,25 +326,34 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
@@ -330,25 +326,34 @@ export function NotificationProvider({ children }: { children: React.ReactNode }