From a2533f58478ff15573f7451da09fb7e2aa090b23 Mon Sep 17 00:00:00 2001 From: Horilla Date: Tue, 26 Aug 2025 11:31:37 +0530 Subject: [PATCH] [UPDT] BASE: Updated notification badge to ensure correct unread count after HTMX swap --- templates/notification/notification_items.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/notification/notification_items.html b/templates/notification/notification_items.html index 9131ca228..1a4cc8ea8 100644 --- a/templates/notification/notification_items.html +++ b/templates/notification/notification_items.html @@ -87,7 +87,7 @@ {% endcomment %}
+ hx-post="{% url 'mark-as-read-notification' notification.id %}" hx-swap="outerHTML" hx-on:click="setTimeout(updateNotificationCount, 500)">
@@ -155,4 +155,13 @@ }); }); }); + + function updateNotificationCount() { + var unreadCount = $(".oh-navbar__notification-item .oh-navbar__notification-dot--unread").length; + + var $badge = $(".live_notify_badge"); + if ($badge.length) { + $badge.text(unreadCount); + } + }