@@ -10,7 +10,6 @@ import {
1010
1111import { select , Store } from '@ngrx/store' ;
1212import { BehaviorSubject , Subscription , take } from 'rxjs' ;
13- import difference from 'lodash/difference' ;
1413
1514import { NotificationsService } from '../notifications.service' ;
1615import { AppState } from '../../../app.reducer' ;
@@ -23,6 +22,7 @@ import {
2322 AccessibilitySetting
2423} from '../../../accessibility/accessibility-settings.service' ;
2524import cloneDeep from 'lodash/cloneDeep' ;
25+ import differenceWith from 'lodash/differenceWith' ;
2626
2727@Component ( {
2828 selector : 'ds-notifications-board' ,
@@ -69,13 +69,13 @@ export class NotificationsBoardComponent implements OnInit, OnDestroy {
6969 this . notifications = [ ] ;
7070 } else if ( state . length > this . notifications . length ) {
7171 // Add
72- const newElem = difference ( state , this . notifications ) ;
72+ const newElem = differenceWith ( state , this . notifications , this . byId ) ;
7373 newElem . forEach ( ( notification ) => {
7474 this . add ( notification ) ;
7575 } ) ;
7676 } else {
7777 // Remove
78- const delElem = difference ( this . notifications , state ) ;
78+ const delElem = differenceWith ( this . notifications , state , this . byId ) ;
7979 delElem . forEach ( ( notification ) => {
8080 this . notifications = this . notifications . filter ( ( item : INotification ) => item . id !== notification . id ) ;
8181
@@ -85,6 +85,9 @@ export class NotificationsBoardComponent implements OnInit, OnDestroy {
8585 } ) ;
8686 }
8787
88+ private byId = ( notificationA : INotification , notificationB : INotification ) =>
89+ notificationA . id === notificationB . id ;
90+
8891 // Add the new notification to the notification array
8992 add ( item : INotification ) : void {
9093 const toBlock : boolean = this . block ( item ) ;
0 commit comments