@@ -44,6 +44,7 @@ const NotificationsDropdown: React.FC = () => {
4444 const { notifications, unreadNotifications, refreshUserData, friends } = useAuth ( ) ;
4545 const navigate = useNavigate ( ) ;
4646 const [ localNotifications , setLocalNotifications ] = React . useState < Notification [ ] > ( notifications ) ;
47+ const [ dismissedIds , setDismissedIds ] = React . useState < Set < string > > ( new Set ( ) ) ;
4748
4849 React . useEffect ( ( ) => {
4950 setLocalNotifications ( notifications ) ;
@@ -53,7 +54,7 @@ const NotificationsDropdown: React.FC = () => {
5354 const result = await acceptFriendRequest ( auth . currentUser ?. uid || '' , senderId ) ;
5455 if ( result ) {
5556 toast . success ( 'Friend request accepted' ) ;
56- setLocalNotifications ( ( prev ) => prev . filter ( n => n . id !== notificationId ) ) ;
57+ setDismissedIds ( prev => new Set ( prev ) . add ( notificationId ) ) ;
5758 refreshUserData ( ) ;
5859 } else {
5960 toast . error ( 'Failed to accept friend request' ) ;
@@ -64,7 +65,7 @@ const NotificationsDropdown: React.FC = () => {
6465 const result = await declineFriendRequest ( auth . currentUser ?. uid || '' , senderId ) ;
6566 if ( result ) {
6667 toast . success ( 'Friend request declined' ) ;
67- setLocalNotifications ( ( prev ) => prev . filter ( n => n . id !== notificationId ) ) ;
68+ setDismissedIds ( prev => new Set ( prev ) . add ( notificationId ) ) ;
6869 refreshUserData ( ) ;
6970 } else {
7071 toast . error ( 'Failed to decline friend request' ) ;
@@ -131,6 +132,7 @@ const NotificationsDropdown: React.FC = () => {
131132 { localNotifications && localNotifications . length > 0 ? (
132133 < DropdownMenuGroup >
133134 { localNotifications
135+ . filter ( n => ! dismissedIds . has ( n . id ) )
134136 . sort ( ( a , b ) => {
135137 let aTime : number ;
136138 let bTime : number ;
0 commit comments