up
This commit is contained in:
+18
-4
@@ -504,6 +504,8 @@ class SimpleWhatsAppManager {
|
||||
// Unread badge
|
||||
const unreadBadge = (conv.unread_count && conv.unread_count > 0) ?
|
||||
`<div class="conversation-unread">${conv.unread_count}</div>` : '';
|
||||
// Add class to highlight unread conversation (darker green)
|
||||
const unreadClass = (conv.unread_count && conv.unread_count > 0) ? ' unread' : '';
|
||||
|
||||
// Status icon
|
||||
const statusIcon = conv.last_direction === 'outgoing'
|
||||
@@ -518,7 +520,7 @@ class SimpleWhatsAppManager {
|
||||
: '';
|
||||
|
||||
html += `
|
||||
<div class="conversation-item" onclick="openChatWindow(${conv.user_id})">
|
||||
<div class="conversation-item${unreadClass}" onclick="openChatWindow(${conv.user_id})">
|
||||
<div class="conversation-avatar ${isOnline ? 'online' : ''}">
|
||||
${userInitial}
|
||||
</div>
|
||||
@@ -622,8 +624,10 @@ class SimpleWhatsAppManager {
|
||||
? '<i class="fas fa-image text-info" title="Imagen"></i> '
|
||||
: '';
|
||||
|
||||
const unreadClass = (conv.unread_count && conv.unread_count > 0) ? ' unread' : '';
|
||||
|
||||
html += `
|
||||
<div class="conversation-item" onclick="openChatWindow(${conv.user_id})">
|
||||
<div class="conversation-item${unreadClass}" onclick="openChatWindow(${conv.user_id})">
|
||||
<div class="conversation-avatar ${isOnline ? 'online' : ''}">
|
||||
${userInitial}
|
||||
</div>
|
||||
@@ -1664,9 +1668,19 @@ window.debugAPI = async function (endpoint) {
|
||||
};
|
||||
|
||||
// Función para abrir ventana de chat
|
||||
window.openChatWindow = function (userId) {
|
||||
window.openChatWindow = async function (userId) {
|
||||
console.log('Abriendo chat del usuario:', userId);
|
||||
|
||||
|
||||
// Marcar conversación como leída en el backend y refrescar lista localmente
|
||||
try {
|
||||
await fetch('api/mark_conversation_read.php', {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({user_id: userId})});
|
||||
if (window.whatsappManager && typeof window.whatsappManager.loadConversations === 'function') {
|
||||
window.whatsappManager.loadConversations();
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('mark_conversation_read failed', e);
|
||||
}
|
||||
|
||||
// Abrir nueva ventana de chat
|
||||
const chatUrl = `chat_window.php?user_id=${userId}&debug=true`;
|
||||
const windowFeatures = 'width=1000,height=700,resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no';
|
||||
|
||||
Reference in New Issue
Block a user