diff --git a/crm/api/notifications.py b/crm/api/notifications.py index f7684e36..972fa58e 100644 --- a/crm/api/notifications.py +++ b/crm/api/notifications.py @@ -31,13 +31,13 @@ def get_notifications(): "notification_text": notification.notification_text, "notification_type_doctype": notification.notification_type_doctype, "notification_type_doc": notification.notification_type_doc, - "reference_doctype": "deal" - if notification.reference_doctype == "CRM Deal" - else "lead", + "reference_doctype": ( + "deal" if notification.reference_doctype == "CRM Deal" else "lead" + ), "reference_name": notification.reference_name, - "route_name": "Deal" - if notification.reference_doctype == "CRM Deal" - else "Lead", + "route_name": ( + "Deal" if notification.reference_doctype == "CRM Deal" else "Lead" + ), } ) @@ -45,12 +45,15 @@ def get_notifications(): @frappe.whitelist() -def mark_as_read(user=None, comment=None): +def mark_as_read(user=None, doc=None): user = user or frappe.session.user filters = {"to_user": user, "read": False} - if comment: - filters["comment"] = comment - for n in frappe.get_all("CRM Notification", filters=filters): + if doc: + or_filters = [ + {"comment": doc}, + {"notification_type_doc": doc}, + ] + for n in frappe.get_all("CRM Notification", filters=filters, or_filters=or_filters): d = frappe.get_doc("CRM Notification", n.name) d.read = True d.save() diff --git a/frontend/src/components/Notifications.vue b/frontend/src/components/Notifications.vue index 9eb8aa22..2781d1ec 100644 --- a/frontend/src/components/Notifications.vue +++ b/frontend/src/components/Notifications.vue @@ -48,7 +48,7 @@ :key="n.comment" :to="getRoute(n)" class="flex cursor-pointer items-start gap-2.5 px-4 py-2.5 hover:bg-gray-100" - @click="mark_as_read(n.comment)" + @click="mark_as_read(n.comment || n.notification_type_doc)" >