mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-05-05 04:52:34 +02:00
fix: Update DM badge using conversations endpoint instead of updates
Changed DM badge update logic to use /api/dm/conversations endpoint
instead of /api/dm/updates?last_seen={} which was causing incorrect
unread counts (showing 99+, then 2, when there should be 0).
The new approach:
- Fetches all conversations with their unread counts
- Sums up unread messages across all conversations
- Updates badge without full page reload (avoiding viewport corruption)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -196,11 +196,16 @@
|
||||
// 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={}');
|
||||
// Fetch latest DM conversations with unread counts
|
||||
const response = await fetch('/api/dm/conversations');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
const totalUnread = data.total_unread || 0;
|
||||
|
||||
// Calculate total unread by summing unread counts from all conversations
|
||||
let totalUnread = 0;
|
||||
if (data.conversations && Array.isArray(data.conversations)) {
|
||||
totalUnread = data.conversations.reduce((sum, conv) => sum + (conv.unread || 0), 0);
|
||||
}
|
||||
|
||||
// Update the green DM badge on notification bell
|
||||
const bellContainer = document.getElementById('notificationBell');
|
||||
|
||||
Reference in New Issue
Block a user