Update conversations.php

This commit is contained in:
Lizandro Guarnizo
2026-01-24 09:02:25 -05:00
parent 44f5c7c7e1
commit d280f94434
+37
View File
@@ -2118,6 +2118,8 @@
if (!initial && Array.isArray(messages) && messages.length === 0) {
try { if (topLoader && topLoader.parentNode) topLoader.remove(); } catch(e) {}
this.hasMoreMessages = false;
// show hint and preserve current view
this.showNoMoreMessagesHint();
// preserve current view and stop further processing
return;
}
@@ -2205,6 +2207,12 @@
// Actualizar estado de paginación
this.hasMoreMessages = hasMore;
// Mostrar o remover el hint "No hay más mensajes anteriores" según corresponda
if (this.hasMoreMessages) {
this.removeNoMoreMessagesHint();
} else {
this.showNoMoreMessagesHint();
}
if (earliest) this.earliestMessage = earliest;
// Renderizar incrementalmente para evitar parpadeos y preservar reproducción de media
@@ -2243,6 +2251,8 @@
if (!initial) {
try { if (topLoader && topLoader.parentNode) topLoader.remove(); } catch (e) {}
this.hasMoreMessages = false;
// Mostrar hint visual
this.showNoMoreMessagesHint();
// Notificar de forma no intrusiva
if (typeof showAlert === 'function') {
showAlert('No se pudieron cargar mensajes anteriores: ' + (error.message || error), 'warning');
@@ -2438,6 +2448,30 @@
}
// Mostrar / quitar hint "No hay más mensajes anteriores"
showNoMoreMessagesHint() {
try {
const container = document.getElementById('chat-conversations');
if (!container) return;
if (container.querySelector('.no-more-messages-hint')) return; // ya existe
const hint = document.createElement('div');
hint.className = 'no-more-messages-hint text-center text-muted';
hint.style.fontSize = '12px';
hint.style.padding = '6px';
hint.textContent = 'No hay más mensajes anteriores';
container.insertBefore(hint, container.firstChild);
} catch (e) { console.warn('showNoMoreMessagesHint failed', e); }
}
removeNoMoreMessagesHint() {
try {
const container = document.getElementById('chat-conversations');
if (!container) return;
const el = container.querySelector('.no-more-messages-hint');
if (el && el.parentNode) el.parentNode.removeChild(el);
} catch (e) { console.warn('removeNoMoreMessagesHint failed', e); }
}
// Initialize recording handlers (so mic works before openConversation) and helper to manage recording state
initRecordingHandlers() {
if (this._recordingHandlersInitialized) return;
@@ -3428,6 +3462,9 @@
document.addEventListener('DOMContentLoaded', () => {
chat = new WhatsAppChat();
window.chatApp = chat; // Exponer globalmente para funciones auxiliares
// Helpers para pruebas manuales y debugging
window.__showNoMoreMessagesHint = () => chat.showNoMoreMessagesHint && chat.showNoMoreMessagesHint();
window.__removeNoMoreMessagesHint = () => chat.removeNoMoreMessagesHint && chat.removeNoMoreMessagesHint();
});
</script>