[UPDT] BASE: Updated notification badge to ensure correct unread count after HTMX swap

This commit is contained in:
Horilla
2025-08-26 11:31:37 +05:30
parent 51f16e8712
commit a2533f5847

View File

@@ -87,7 +87,7 @@
{% endcomment %}
<div class="oh-navbar__notification-image" style="margin-left: 5px"
onclick="event.stopPropagation();event.preventDefault();" hx-target="#notificationItem{{notification.id}}"
hx-post="{% url 'mark-as-read-notification' notification.id %}" hx-swap="outerHTML">
hx-post="{% url 'mark-as-read-notification' notification.id %}" hx-swap="outerHTML" hx-on:click="setTimeout(updateNotificationCount, 500)">
<ion-icon name="checkmark-outline"></ion-icon>
</div>
</div>
@@ -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);
}
}
</script>