diff --git a/app/templates/index.html b/app/templates/index.html
index 568a464..717b775 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -193,9 +193,36 @@
}
});
- // Reload page when DM modal is closed to update unread badges
- dmModal.addEventListener('hidden.bs.modal', function () {
- window.location.reload();
+ // Update DM badges when modal is closed (without full page reload)
+ dmModal.addEventListener('hidden.bs.modal', async function () {
+ try {
+ // Fetch latest DM unread counts
+ const response = await fetch('/api/dm/updates?last_seen={}');
+ if (response.ok) {
+ const data = await response.json();
+ const totalUnread = data.total_unread || 0;
+
+ // Update the green DM badge on notification bell
+ const bellContainer = document.getElementById('notificationBell');
+ if (bellContainer) {
+ let dmBadge = bellContainer.querySelector('.notification-badge-dm');
+
+ if (totalUnread > 0) {
+ if (!dmBadge) {
+ dmBadge = document.createElement('span');
+ dmBadge.className = 'notification-badge-dm';
+ bellContainer.appendChild(dmBadge);
+ }
+ dmBadge.textContent = totalUnread > 99 ? '99+' : totalUnread;
+ dmBadge.style.display = 'inline-block';
+ } else if (dmBadge) {
+ dmBadge.style.display = 'none';
+ }
+ }
+ }
+ } catch (error) {
+ console.error('Error updating DM badges:', error);
+ }
});
}