Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Prevent re-emitting the same collections with a trackBy

Oliver Günther2c9e48ff4b07
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
index abe43f402a2..6c51edb5e83 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
@@ -6,7 +6,7 @@
class="op-ian-center--viewport"
>
<op-in-app-notification-entry
- *cdkVirtualFor="let records of notifications$ | async; templateCacheSize: 0"
+ *cdkVirtualFor="let records of notifications$ | async; trackBy: trackNotificationGroups; templateCacheSize: 0"
class="op-ian-center--entry"
[notification]="records[0]"
[aggregatedNotifications]="records"
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
index 246c7749d3b..ec348e5354e 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
@@ -14,7 +14,10 @@ import { StateService } from '@uirouter/angular';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { UIRouterGlobals } from '@uirouter/core';
import { IanCenterService } from 'core-app/features/in-app-notifications/center/state/ian-center.service';
-import { NOTIFICATIONS_MAX_SIZE } from 'core-app/core/state/in-app-notifications/in-app-notification.model';
+import {
+ InAppNotification,
+ NOTIFICATIONS_MAX_SIZE,
+} from 'core-app/core/state/in-app-notifications/in-app-notification.model';
@Component({
selector: 'op-in-app-notification-center',
@@ -53,6 +56,10 @@ export class InAppNotificationCenterComponent implements OnInit {
originalOrder = ():number => 0;
+ trackNotificationGroups = (i:number, item:InAppNotification[]):string => item
+ .map((el) => `${el.id}@${el.updatedAt}`)
+ .join(',');
+
text = {
title: this.I18n.t('js.notifications.title'),
button_close: this.I18n.t('js.button_close'),
@@ -69,7 +76,8 @@ export class InAppNotificationCenterComponent implements OnInit {
readonly storeService:IanCenterService,
readonly uiRouterGlobals:UIRouterGlobals,
readonly state:StateService,
- ) { }
+ ) {
+ }
ngOnInit():void {
this.storeService.setFacet('unread');