From e7e81284102e0ea60969e89a12281bed2d64f761 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 14 Nov 2019 12:00:47 +0530 Subject: [PATCH] fix: Common method to toggle seen --- .../frappe/ui/notifications/notifications.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/frappe/public/js/frappe/ui/notifications/notifications.js b/frappe/public/js/frappe/ui/notifications/notifications.js index c2e6ccaa81..88328c7b09 100644 --- a/frappe/public/js/frappe/ui/notifications/notifications.js +++ b/frappe/public/js/frappe/ui/notifications/notifications.js @@ -225,7 +225,7 @@ frappe.ui.Notifications = class Notifications { change_activity_status() { if (this.$dropdown_list.find('.activity-status')) { this.$dropdown_list.find('.activity-status').replaceWith( - `
${__('View Full Log')}
` @@ -270,10 +270,10 @@ frappe.ui.Notifications = class Notifications { ); } - mark_as_seen() { + toggle_seen(flag) { frappe.call( 'frappe.desk.doctype.notification_settings.notification_settings.set_seen_value', - { value: 1 } + { value: cint(flag) } ); } @@ -331,7 +331,7 @@ frappe.ui.Notifications = class Notifications { let user = field.from_user; let user_avatar = frappe.avatar(user, 'avatar-small user-avatar'); let timestamp = frappe.datetime.comment_when(field.creation, true); - let item_html = + let item_html = `
  • ${category.label} @@ -442,11 +442,8 @@ frappe.ui.Notifications = class Notifications { frappe.realtime.on('notification', () => { 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.toggle_seen(false); + } this.$dropdown.find('.notifications-indicator').show(); this.update_dropdown(); }); @@ -471,7 +468,7 @@ frappe.ui.Notifications = class Notifications { }); this.$dropdown.on('show.bs.dropdown', () => { - this.mark_as_seen(); + this.toggle_seen(true); if (this.$notification_indicator.is(':visible')) { this.$notification_indicator.hide(); frappe.call( @@ -530,4 +527,4 @@ frappe.ui.notifications = { } frappe.set_route('List', doctype); } -}; \ No newline at end of file +};