diff --git a/calendario.html b/calendario.html index a05ef41..1931af3 100644 --- a/calendario.html +++ b/calendario.html @@ -892,7 +892,23 @@ } } - async function loadChat(serviceId) { + async function loadChat(serviceId) { + // 🔔 MARCAR COMO LEÍDO AL ABRIR EL CHAT + try { + fetch(`${API_URL}/services/${serviceId}/chat/read`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${localStorage.getItem("token")}` + } + }).then(() => { + // Refrescar el globo de notificaciones inmediatamente para que desaparezca + if (typeof checkNotifications === "function") checkNotifications(); + }); + } catch (e) { + console.error("Error al marcar lectura:", e); + } + const chatBox = document.getElementById('chatBox'); chatBox.innerHTML = '
Cargando...
'; safeLoadIcons();