From aa59b0561c2b7a08eac84ec8128b3d344a574c8f Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Sat, 24 Jan 2026 09:18:34 -0500 Subject: [PATCH] Revert "Update conversations.php" This reverts commit 38237eaf13e1109d74c2a79b9df40ec5c86f5ef3. --- conversations.php | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/conversations.php b/conversations.php index f14a539..6f57b13 100644 --- a/conversations.php +++ b/conversations.php @@ -2091,8 +2091,6 @@ } try { - console.debug('loadMessages called', { userId, initial, earliestMessage: this.earliestMessage, earliestMessageId: this.earliestMessageId, currentCount: this.conversations ? this.conversations.length : 0 }); - let url = `get_user_messages.php?user_id=${userId}&limit=${this.messageLimit}`; if (!initial && this.earliestMessage) { url += `&before=${encodeURIComponent(this.earliestMessage)}`; @@ -2141,14 +2139,6 @@ } } - // Si estamos en carga inicial y el servidor devolvió array vacío, pero ya teníamos mensajes en la vista, - // *no* reemplazaremos el arreglo existente (evita borrar la conversación por un fallo temporal del API). - if (initial && Array.isArray(messages) && messages.length === 0 && Array.isArray(this.conversations) && this.conversations.length > 0) { - console.warn('Initial load returned empty but existing view contains messages - preserving current conversation'); - if (typeof showAlert === 'function') showAlert('No se pudieron recargar mensajes; manteniendo historial actual', 'warning'); - return; - } - // Guard: cuando paginamos (initial=false) y la respuesta no trae mensajes, // no reemplazar ni limpiar la conversación actual; solo indicar que no hay más. if (!initial && Array.isArray(messages) && messages.length === 0) { @@ -2186,22 +2176,6 @@ this.conversations = messages.concat(this.conversations); } - // Limpieza: eliminar mensajes vacíos persistentes en la vista (text vacíos sin media) - try { - if (Array.isArray(this.conversations) && this.conversations.length > 0) { - const before = this.conversations.length; - this.conversations = this.conversations.filter(m => { - if (!m) return false; - const content = (typeof m.content !== 'undefined' && m.content !== null) ? String(m.content).trim() : ''; - const hasMedia = !!(m.local_thumb || m.local_file || m.media_url_external || m.media_url); - const nonText = m.message_type && m.message_type !== 'text'; - return (hasMedia || nonText || content.length > 0); - }); - const cleaned = before - this.conversations.length; - if (cleaned > 0) console.info('Removed', cleaned, 'empty text-only messages from conversation view'); - } - } catch (e) { console.warn('Failed to clean conversation entries', e); } - // Actualizar paginación (earliest timestamp y id) if (earliest) this.earliestMessage = earliest; if (typeof earliestId !== 'undefined' && earliestId !== null) this.earliestMessageId = earliestId;