Update conversations.php
This commit is contained in:
@@ -2118,6 +2118,8 @@
|
|||||||
if (!initial && Array.isArray(messages) && messages.length === 0) {
|
if (!initial && Array.isArray(messages) && messages.length === 0) {
|
||||||
try { if (topLoader && topLoader.parentNode) topLoader.remove(); } catch(e) {}
|
try { if (topLoader && topLoader.parentNode) topLoader.remove(); } catch(e) {}
|
||||||
this.hasMoreMessages = false;
|
this.hasMoreMessages = false;
|
||||||
|
// show hint and preserve current view
|
||||||
|
this.showNoMoreMessagesHint();
|
||||||
// preserve current view and stop further processing
|
// preserve current view and stop further processing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2205,6 +2207,12 @@
|
|||||||
|
|
||||||
// Actualizar estado de paginación
|
// Actualizar estado de paginación
|
||||||
this.hasMoreMessages = hasMore;
|
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;
|
if (earliest) this.earliestMessage = earliest;
|
||||||
|
|
||||||
// Renderizar incrementalmente para evitar parpadeos y preservar reproducción de media
|
// Renderizar incrementalmente para evitar parpadeos y preservar reproducción de media
|
||||||
@@ -2243,6 +2251,8 @@
|
|||||||
if (!initial) {
|
if (!initial) {
|
||||||
try { if (topLoader && topLoader.parentNode) topLoader.remove(); } catch (e) {}
|
try { if (topLoader && topLoader.parentNode) topLoader.remove(); } catch (e) {}
|
||||||
this.hasMoreMessages = false;
|
this.hasMoreMessages = false;
|
||||||
|
// Mostrar hint visual
|
||||||
|
this.showNoMoreMessagesHint();
|
||||||
// Notificar de forma no intrusiva
|
// Notificar de forma no intrusiva
|
||||||
if (typeof showAlert === 'function') {
|
if (typeof showAlert === 'function') {
|
||||||
showAlert('No se pudieron cargar mensajes anteriores: ' + (error.message || error), 'warning');
|
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
|
// Initialize recording handlers (so mic works before openConversation) and helper to manage recording state
|
||||||
initRecordingHandlers() {
|
initRecordingHandlers() {
|
||||||
if (this._recordingHandlersInitialized) return;
|
if (this._recordingHandlersInitialized) return;
|
||||||
@@ -3428,6 +3462,9 @@
|
|||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
chat = new WhatsAppChat();
|
chat = new WhatsAppChat();
|
||||||
window.chatApp = chat; // Exponer globalmente para funciones auxiliares
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user