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

use bulk read end point

ulferts9d5c95f28988
diff --git a/frontend/src/app/core/apiv3/endpoints/notifications/apiv3-notifications-paths.ts b/frontend/src/app/core/apiv3/endpoints/notifications/apiv3-notifications-paths.ts
index f8271f6605f..083edfec8c1 100644
--- a/frontend/src/app/core/apiv3/endpoints/notifications/apiv3-notifications-paths.ts
+++ b/frontend/src/app/core/apiv3/endpoints/notifications/apiv3-notifications-paths.ts
@@ -35,6 +35,7 @@ import { Apiv3NotificationPaths } from "core-app/core/apiv3/endpoints/notificati
import { InjectField } from "core-app/shared/helpers/angular/inject-field.decorator";
import { HttpClient } from "@angular/common/http";
import { IHALCollection } from "core-app/core/apiv3/types/hal-collection.type";
+import { ID } from "@datorama/akita";
export class Apiv3NotificationsPaths
extends APIv3ResourceCollection<InAppNotification, Apiv3NotificationPaths> {
@@ -74,4 +75,21 @@ export class Apiv3NotificationsPaths
return this.list(params);
}
+
+ /**
+ * Mark all notifications as read
+ * @param ids
+ */
+ public markRead(ids:Array<ID>):Observable<unknown> {
+ return this
+ .http
+ .post(
+ this.path + '/read_ian' + listParamsString({ filters: [['id', "=", ids.map(id => id.toString())]] }),
+ {},
+ {
+ withCredentials: true,
+ responseType: 'json'
+ }
+ );
+ }
}
diff --git a/frontend/src/app/features/in-app-notifications/store/in-app-notifications.service.ts b/frontend/src/app/features/in-app-notifications/store/in-app-notifications.service.ts
index 2b76a9c3a36..8d14cbbe3e7 100644
--- a/frontend/src/app/features/in-app-notifications/store/in-app-notifications.service.ts
+++ b/frontend/src/app/features/in-app-notifications/store/in-app-notifications.service.ts
@@ -86,9 +86,7 @@ export class InAppNotificationsService {
.pipe(
take(1),
switchMap(events =>
- forkJoin(
- events.map(event => this.apiV3Service.notifications.id(event.id).markRead())
- )
+ this.apiV3Service.notifications.markRead(events.map(event => event.id))
)
)
.subscribe(() => {