mejoras
This commit is contained in:
+15
-15
@@ -52,7 +52,7 @@ if (empty($user_id)) {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
.chat-conversations {
|
||||
flex: 1;
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
@@ -367,7 +367,7 @@ if (empty($user_id)) {
|
||||
</div>
|
||||
|
||||
<!-- Mensajes del chat -->
|
||||
<div class="chat-messages" id="chatMessages">
|
||||
<div class="chat-conversations" id="chatconversations">
|
||||
<div class="d-flex justify-content-center">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="visually-hidden">Cargando mensajes...</span>
|
||||
@@ -536,7 +536,7 @@ if (empty($user_id)) {
|
||||
`<span>${(currentUser.name || 'U').charAt(0).toUpperCase()}</span>`;
|
||||
|
||||
// Cargar mensajes
|
||||
displayMessages(response.messages);
|
||||
displayconversations(response.conversations);
|
||||
|
||||
// Cargar plantillas
|
||||
loadTemplates();
|
||||
@@ -551,11 +551,11 @@ if (empty($user_id)) {
|
||||
}
|
||||
|
||||
// Mostrar mensajes
|
||||
function displayMessages(messages) {
|
||||
const chatMessages = document.getElementById('chatMessages');
|
||||
function displayconversations(conversations) {
|
||||
const chatconversations = document.getElementById('chatconversations');
|
||||
|
||||
if (!messages || messages.length === 0) {
|
||||
chatMessages.innerHTML = `
|
||||
if (!conversations || conversations.length === 0) {
|
||||
chatconversations.innerHTML = `
|
||||
<div class="text-center text-muted py-5">
|
||||
<i class="fas fa-comments fa-3x mb-3"></i>
|
||||
<br>No hay mensajes en esta conversación
|
||||
@@ -566,7 +566,7 @@ if (empty($user_id)) {
|
||||
}
|
||||
|
||||
let html = '';
|
||||
messages.forEach(msg => {
|
||||
conversations.forEach(msg => {
|
||||
const isOutgoing = msg.direction === 'outgoing';
|
||||
const messageClass = isOutgoing ? 'message-outgoing' : 'message-incoming';
|
||||
|
||||
@@ -643,7 +643,7 @@ if (empty($user_id)) {
|
||||
`;
|
||||
});
|
||||
|
||||
chatMessages.innerHTML = html;
|
||||
chatconversations.innerHTML = html;
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
@@ -804,7 +804,7 @@ if (empty($user_id)) {
|
||||
|
||||
// Agregar mensaje a la vista
|
||||
function addMessageToView(message, direction) {
|
||||
const chatMessages = document.getElementById('chatMessages');
|
||||
const chatconversations = document.getElementById('chatconversations');
|
||||
const isOutgoing = direction === 'outgoing';
|
||||
const messageClass = isOutgoing ? 'message-outgoing' : 'message-incoming';
|
||||
const now = new Date().toLocaleTimeString('es-ES', { hour: '2-digit', minute: '2-digit' });
|
||||
@@ -820,7 +820,7 @@ if (empty($user_id)) {
|
||||
</div>
|
||||
`;
|
||||
|
||||
chatMessages.insertAdjacentHTML('beforeend', messageHtml);
|
||||
chatconversations.insertAdjacentHTML('beforeend', messageHtml);
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
@@ -835,8 +835,8 @@ if (empty($user_id)) {
|
||||
|
||||
// Scroll al final
|
||||
function scrollToBottom() {
|
||||
const chatMessages = document.getElementById('chatMessages');
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
const chatconversations = document.getElementById('chatconversations');
|
||||
chatconversations.scrollTop = chatconversations.scrollHeight;
|
||||
}
|
||||
|
||||
// Refrescar chat
|
||||
@@ -1146,7 +1146,7 @@ if (empty($user_id)) {
|
||||
|
||||
// Renderizar mensaje multimedia
|
||||
function renderMediaMessage(message, type, timestamp = null) {
|
||||
const chatMessages = document.getElementById('chatMessages');
|
||||
const chatconversations = document.getElementById('chatconversations');
|
||||
const messageDiv = document.createElement('div');
|
||||
messageDiv.className = `message-bubble message-${type}`;
|
||||
|
||||
@@ -1183,7 +1183,7 @@ if (empty($user_id)) {
|
||||
}
|
||||
|
||||
messageDiv.innerHTML = html;
|
||||
chatMessages.appendChild(messageDiv);
|
||||
chatconversations.appendChild(messageDiv);
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user