diff --git a/frappe/desk/doctype/notification_log/notification_log.json b/frappe/desk/doctype/notification_log/notification_log.json
index c49a6bd428..ecb746df64 100644
--- a/frappe/desk/doctype/notification_log/notification_log.json
+++ b/frappe/desk/doctype/notification_log/notification_log.json
@@ -11,7 +11,6 @@
"column_break_4",
"document_type",
"read",
- "seen",
"document_name",
"from_user"
],
@@ -58,13 +57,6 @@
"read_only": 1,
"search_index": 1
},
- {
- "default": "0",
- "fieldname": "seen",
- "fieldtype": "Check",
- "hidden": 1,
- "label": "Seen"
- },
{
"fieldname": "document_name",
"fieldtype": "Data",
@@ -90,7 +82,7 @@
}
],
"in_create": 1,
- "modified": "2019-11-07 20:42:07.548645",
+ "modified": "2019-11-12 15:22:35.283678",
"modified_by": "umair@erpnext.com",
"module": "Desk",
"name": "Notification Log",
diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py
index 96f1d5080a..6f27fa4f44 100644
--- a/frappe/desk/doctype/notification_log/notification_log.py
+++ b/frappe/desk/doctype/notification_log/notification_log.py
@@ -112,13 +112,11 @@ def get_title_html(title):
return '{0}'.format(title)
@frappe.whitelist()
-def set_all_values_for_field(docnames, fieldname):
+def mark_all_as_read(docnames):
docnames = frappe.parse_json(docnames)
- event_name = 'all_' + fieldname
if docnames:
filters = {'name': ['in', docnames]}
- frappe.db.set_value('Notification Log', filters, fieldname, 1, update_modified=False)
- frappe.publish_realtime(event_name, after_commit=True, user=frappe.session.user)
+ frappe.db.set_value('Notification Log', filters, 'read', 1, update_modified=False)
@frappe.whitelist()
def mark_as_read(docname):
diff --git a/frappe/desk/doctype/notification_settings/notification_settings.json b/frappe/desk/doctype/notification_settings/notification_settings.json
index c2f3633d63..a162105299 100644
--- a/frappe/desk/doctype/notification_settings/notification_settings.json
+++ b/frappe/desk/doctype/notification_settings/notification_settings.json
@@ -13,7 +13,8 @@
"enable_email_assignment",
"enable_email_energy_point",
"enable_email_share",
- "user"
+ "user",
+ "seen"
],
"fields": [
{
@@ -75,11 +76,18 @@
"label": "User",
"options": "User",
"read_only": 1
+ },
+ {
+ "default": "0",
+ "fieldname": "seen",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "label": "Seen"
}
],
"in_create": 1,
- "modified": "2019-11-08 14:11:35.619306",
- "modified_by": "frappetestuser2@gmail.com",
+ "modified": "2019-11-12 14:50:16.822761",
+ "modified_by": "Administrator",
"module": "Desk",
"name": "Notification Settings",
"owner": "Administrator",
diff --git a/frappe/desk/doctype/notification_settings/notification_settings.py b/frappe/desk/doctype/notification_settings/notification_settings.py
index 3bb3cf9320..1ac4e2b1dd 100644
--- a/frappe/desk/doctype/notification_settings/notification_settings.py
+++ b/frappe/desk/doctype/notification_settings/notification_settings.py
@@ -60,3 +60,7 @@ def get_permission_query_conditions(user):
if not user: user = frappe.session.user
return '''(`tabNotification Settings`.user = '{user}')'''.format(user=user)
+
+@frappe.whitelist()
+def set_seen_value(value):
+ frappe.db.set_value('Notification Settings', frappe.session.user, 'seen', value, update_modified=False)
\ No newline at end of file
diff --git a/frappe/public/js/frappe/ui/notifications/notifications.js b/frappe/public/js/frappe/ui/notifications/notifications.js
index 0c41f19300..c2e6ccaa81 100644
--- a/frappe/public/js/frappe/ui/notifications/notifications.js
+++ b/frappe/public/js/frappe/ui/notifications/notifications.js
@@ -59,8 +59,7 @@ frappe.ui.Notifications = class Notifications {
this.get_notifications_list(this.max_length).then(list => {
this.dropdown_items = list;
this.render_notifications_dropdown();
-
- if (this.$notifications.find('.unseen').length) {
+ if (this.notifications_settings.seen == 0) {
this.$notification_indicator.show();
}
});
@@ -264,26 +263,17 @@ frappe.ui.Notifications = class Notifications {
.map(d => d.name);
if (!unread_docnames.length) return;
frappe.call(
- 'frappe.desk.doctype.notification_log.notification_log.set_all_values_for_field',
+ 'frappe.desk.doctype.notification_log.notification_log.mark_all_as_read',
{
docnames: unread_docnames,
- fieldname: 'read'
}
);
}
- mark_all_as_seen() {
- this.$dropdown_list.find('.unseen').removeClass('unseen');
- let unseen_docnames = this.dropdown_items
- .filter(item => item.seen === 0)
- .map(d => d.name);
- if (!unseen_docnames.length) return;
+ mark_as_seen() {
frappe.call(
- 'frappe.desk.doctype.notification_log.notification_log.set_all_values_for_field',
- {
- docnames: unseen_docnames,
- fieldname: 'seen'
- }
+ 'frappe.desk.doctype.notification_settings.notification_settings.set_seen_value',
+ { value: 1 }
);
}
@@ -333,7 +323,6 @@ frappe.ui.Notifications = class Notifications {
field.document_name
);
let read_class = field.read ? '' : 'unread';
- let seen_class = field.seen ? '' : 'unseen';
let mark_read_action = field.read ? '': 'data-action="mark_as_read"';
let message = field.subject;
let title = message.match(/(.*?)<\/b>/);
@@ -343,7 +332,7 @@ frappe.ui.Notifications = class Notifications {
let user_avatar = frappe.avatar(user, 'avatar-small user-avatar');
let timestamp = frappe.datetime.comment_when(field.creation, true);
let item_html =
- ` {
+ if (this.notifications_settings.seen == 1) {
+ this.notifications_settings.seen = 0;
+ frappe.call(
+ 'frappe.desk.doctype.notification_settings.notification_settings.set_seen_value',
+ { value: 0 }
+ );
+ }
this.$dropdown.find('.notifications-indicator').show();
this.update_dropdown();
});
@@ -475,7 +471,7 @@ frappe.ui.Notifications = class Notifications {
});
this.$dropdown.on('show.bs.dropdown', () => {
- this.mark_all_as_seen();
+ this.mark_as_seen();
if (this.$notification_indicator.is(':visible')) {
this.$notification_indicator.hide();
frappe.call(