diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py index ca699bbcbd..8f43cdc2b9 100644 --- a/frappe/desk/doctype/notification_log/notification_log.py +++ b/frappe/desk/doctype/notification_log/notification_log.py @@ -94,3 +94,4 @@ def mark_as_seen(docnames): if docnames: filters = {'name': ['in', docnames]} frappe.db.set_value('Notification Log', filters, 'seen', 1, update_modified=False) + frappe.publish_realtime('seen_notification', after_commit=True, user=frappe.session.user) diff --git a/frappe/public/js/frappe/ui/notifications/notifications.js b/frappe/public/js/frappe/ui/notifications/notifications.js index a41e931402..ddbd8a3f9e 100644 --- a/frappe/public/js/frappe/ui/notifications/notifications.js +++ b/frappe/public/js/frappe/ui/notifications/notifications.js @@ -375,7 +375,7 @@ frappe.ui.Notifications = class Notifications { } bind_events() { - this.setup_notification_listener(); + this.setup_notification_listeners(); this.setup_dropdown_events(); this.$dropdown_list.on('click', '.recent-item', () => { @@ -391,11 +391,15 @@ frappe.ui.Notifications = class Notifications { }); } - setup_notification_listener() { + setup_notification_listeners() { frappe.realtime.on('notification', () => { this.$dropdown.find('.notifications-indicator').show(); this.update_dropdown(); }); + + frappe.realtime.on('seen_notification', () => { + this.$dropdown.find('.notifications-indicator').hide(); + }); } setup_dropdown_events() { @@ -407,7 +411,6 @@ frappe.ui.Notifications = class Notifications { toggle: false }); this.$dropdown.on('hide.bs.dropdown', e => { - this.$notification_indicator.hide(); let hide = $(e.currentTarget).data('closable'); if (hide) { this.$dropdown_list