Skip to content

EspoCRM – Open Source CRM Application

Mark grouped notifications as read if record link clicked

Yurii4a51a8a3fc4e
diff --git a/client/src/views/notification/fields/container.js b/client/src/views/notification/fields/container.js
index f3eac60c63..f3c7ad9f86 100644
--- a/client/src/views/notification/fields/container.js
+++ b/client/src/views/notification/fields/container.js
@@ -325,7 +325,7 @@ class NotificationContainerFieldView extends BaseFieldView {
}
/**
- * @private
+ * @internal
*/
triggerUpdateRead() {
let viewPointer = this;
diff --git a/client/src/views/notification/items/group-note.js b/client/src/views/notification/items/group-note.js
index 9402d38d61..d23cbe8751 100644
--- a/client/src/views/notification/items/group-note.js
+++ b/client/src/views/notification/items/group-note.js
@@ -27,6 +27,8 @@
************************************************************************/
import BaseNotificationItemView from 'views/notification/items/base';
+import Ajax from 'ajax';
+import NotificationContainerFieldView from 'views/notification/fields/container';
// noinspection JSUnusedGlobalSymbols
export default class GroupNoteNotificationItemView extends BaseNotificationItemView {
@@ -98,5 +100,38 @@ export default class GroupNoteNotificationItemView extends BaseNotificationItemV
}
this.createMessage();
+
+ this.addHandler('click',
+ '> .stream-head-container > .stream-head-text-container [data-key="entity"] a', () => {
+ this.markGroupRead();
+ });
+ }
+
+ /**
+ * @private
+ */
+ async markGroupRead() {
+ if (this.model.attributes.read) {
+ return;
+ }
+
+ await Ajax.postRequest(`Notification/group/${this.model.id}/markRead`);
+
+ this.model.set('read', true, {sync: true});
+
+ this.triggerUpdateRead();
+ }
+
+ /**
+ * @private
+ */
+ triggerUpdateRead() {
+ const parentView = this.getParentView();
+
+ if (!(parentView instanceof NotificationContainerFieldView)) {
+ return;
+ }
+
+ parentView.triggerUpdateRead();
}
}