From 271f179b0047f9c1ec85893a19e88873acd59948 Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Tue, 31 Mar 2026 12:52:15 +0530 Subject: [PATCH 1/4] refactor: remove unnecessary console log --- frappe/public/js/frappe/ui/notifications/notifications.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frappe/public/js/frappe/ui/notifications/notifications.js b/frappe/public/js/frappe/ui/notifications/notifications.js index a7d40e0cf9..b87dcfd8f1 100644 --- a/frappe/public/js/frappe/ui/notifications/notifications.js +++ b/frappe/public/js/frappe/ui/notifications/notifications.js @@ -34,7 +34,6 @@ frappe.ui.Notifications = class Notifications { `) .on("click", (e) => { e.stopImmediatePropagation(); - console.log("what"); frappe.set_route("Form", "Notification Settings", frappe.session.user); }) .appendTo(this.header_actions) From ecc43b95b1faffb6af4f4521d604be286126f8c8 Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Tue, 31 Mar 2026 21:58:07 +0530 Subject: [PATCH 2/4] perf: load notifications and events on demand --- .../frappe/ui/notifications/notifications.js | 72 +++++++++++++------ frappe/public/js/frappe/ui/sidebar/sidebar.js | 6 +- 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/frappe/public/js/frappe/ui/notifications/notifications.js b/frappe/public/js/frappe/ui/notifications/notifications.js index b87dcfd8f1..ec91f15291 100644 --- a/frappe/public/js/frappe/ui/notifications/notifications.js +++ b/frappe/public/js/frappe/ui/notifications/notifications.js @@ -223,15 +223,13 @@ class NotificationsView extends BaseNotificationsView { .tooltip({ delay: { show: 600, hide: 100 }, trigger: "hover" }); this.setup_notification_listeners(); - this.get_notifications_list(this.max_length).then((r) => { - if (!r.message) return; - this.dropdown_items = r.message.notification_logs; - frappe.update_user_info(r.message.user_info); - this.render_notifications_dropdown(); - if (this.settings.seen == 0 && this.dropdown_items.length > 0) { - this.toggle_notification_icon(false); - } - }); + + this.dropdown_items = []; + this.notifications_fetched = false + + if (this.settings && this.settings.seen == 0) { + this.toggle_notification_icon(false); + } } update_dropdown() { @@ -407,6 +405,21 @@ class NotificationsView extends BaseNotificationsView { }); this.parent.on("show.bs.dropdown", () => { + if (!this.notifications_fetched) { + this.container.html(`
+
+
+
+
`); + this.get_notifications_list(this.max_length).then((r) => { + if (!r.message) return; + this.dropdown_items = r.message.notification_logs; + frappe.update_user_info(r.message.user_info); + this.render_notifications_dropdown(); + this.notifications_fetched = true; + }); + } + this.toggle_seen(true); if (this.notifications_icon.find(".notifications-unseen").is(":visible")) { this.toggle_notification_icon(true); @@ -420,20 +433,33 @@ class NotificationsView extends BaseNotificationsView { class EventsView extends BaseNotificationsView { make() { - let today = frappe.datetime.get_today(); - frappe - .xcall( - "frappe.desk.doctype.event.event.get_events", - { - start: today, - end: today, - }, - "GET", - { cache: true } - ) - .then((event_list) => { - this.render_events_html(event_list); - }); + this.events_fetched = false; + + this.parent.on("show.bs.dropdown", () => { + if (this.events_fetched) return; + + this.container.html(`
+
+
+
+
`); + + let today = frappe.datetime.get_today(); + frappe + .xcall( + "frappe.desk.doctype.event.event.get_events", + { + start: today, + end: today, + }, + "GET", + { cache: true } + ) + .then((event_list) => { + this.render_events_html(event_list); + this.events_fetched = true; + }); + }); } render_events_html(event_list) { diff --git a/frappe/public/js/frappe/ui/sidebar/sidebar.js b/frappe/public/js/frappe/ui/sidebar/sidebar.js index 9b3d4c3a97..10a7f3161c 100644 --- a/frappe/public/js/frappe/ui/sidebar/sidebar.js +++ b/frappe/public/js/frappe/ui/sidebar/sidebar.js @@ -484,7 +484,11 @@ frappe.ui.Sidebar = class Sidebar { type: "Button", class: "sidebar-notification hidden", onClick: () => { - this.wrapper.find(".dropdown-notifications").toggleClass("hidden"); + const $dropdown = this.wrapper.find(".dropdown-notifications"); + $dropdown.toggleClass("hidden"); + if (!$dropdown.hasClass("hidden")) { + $dropdown.trigger("show.bs.dropdown"); + } if (frappe.is_mobile()) { this.wrapper.removeClass("expanded"); } From 73b757c201af4f5b87c9580c1d81507555b6436e Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Tue, 31 Mar 2026 22:59:03 +0530 Subject: [PATCH 3/4] chore: fix formatting --- frappe/public/js/frappe/ui/notifications/notifications.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/ui/notifications/notifications.js b/frappe/public/js/frappe/ui/notifications/notifications.js index ec91f15291..91a6cf2807 100644 --- a/frappe/public/js/frappe/ui/notifications/notifications.js +++ b/frappe/public/js/frappe/ui/notifications/notifications.js @@ -224,8 +224,8 @@ class NotificationsView extends BaseNotificationsView { this.setup_notification_listeners(); - this.dropdown_items = []; - this.notifications_fetched = false + this.dropdown_items = []; + this.notifications_fetched = false; if (this.settings && this.settings.seen == 0) { this.toggle_notification_icon(false); From 381f5e5c0698fe4847cf2450cbfbdc6a43134921 Mon Sep 17 00:00:00 2001 From: Shrihari Mahabal Date: Mon, 6 Apr 2026 18:50:31 +0530 Subject: [PATCH 4/4] fix: set notifications list to empty when no notifications --- .../js/frappe/ui/notifications/notifications.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/ui/notifications/notifications.js b/frappe/public/js/frappe/ui/notifications/notifications.js index 91a6cf2807..70f61c7f8d 100644 --- a/frappe/public/js/frappe/ui/notifications/notifications.js +++ b/frappe/public/js/frappe/ui/notifications/notifications.js @@ -344,7 +344,7 @@ class NotificationsView extends BaseNotificationsView {
${__("See all Activity")}
`); } else { - this.container.append( + this.container.html( $(`
Generic Empty State @@ -412,9 +412,12 @@ class NotificationsView extends BaseNotificationsView {
`); this.get_notifications_list(this.max_length).then((r) => { - if (!r.message) return; - this.dropdown_items = r.message.notification_logs; - frappe.update_user_info(r.message.user_info); + if (r.message && r.message.notification_logs) { + this.dropdown_items = r.message.notification_logs; + frappe.update_user_info(r.message.user_info); + } else { + this.dropdown_items = []; + } this.render_notifications_dropdown(); this.notifications_fetched = true; });