Update conversations.php
This commit is contained in:
@@ -2814,6 +2814,8 @@
|
|||||||
// Si es carga inicial y el servidor devolvió vacío, pero ya teníamos mensajes, preservarlos.
|
// Si es carga inicial y el servidor devolvió vacío, pero ya teníamos mensajes, preservarlos.
|
||||||
if (initial && Array.isArray(messages) && messages.length === 0 && Array.isArray(this.conversations) && this.conversations.length > 0) {
|
if (initial && Array.isArray(messages) && messages.length === 0 && Array.isArray(this.conversations) && this.conversations.length > 0) {
|
||||||
try { if (topLoader && topLoader.parentNode) topLoader.remove(); } catch(e) {}
|
try { if (topLoader && topLoader.parentNode) topLoader.remove(); } catch(e) {}
|
||||||
|
// Ensure container visibility is restored if it was hidden during render
|
||||||
|
try { if (container && container.dataset && container.dataset.renderHidden) { container.style.visibility = 'visible'; delete container.dataset.renderHidden; } } catch(e) {}
|
||||||
this.loadingMessages = false;
|
this.loadingMessages = false;
|
||||||
if (typeof showAlert === 'function') showAlert('No se pudieron recargar mensajes; manteniendo historial actual', 'warning');
|
if (typeof showAlert === 'function') showAlert('No se pudieron recargar mensajes; manteniendo historial actual', 'warning');
|
||||||
console.warn('Initial load returned empty but existing view contains messages - preserving current conversation');
|
console.warn('Initial load returned empty but existing view contains messages - preserving current conversation');
|
||||||
@@ -2967,6 +2969,13 @@
|
|||||||
if (initial) {
|
if (initial) {
|
||||||
// Scroll to bottom only if the caller requested following behavior
|
// Scroll to bottom only if the caller requested following behavior
|
||||||
if (follow) { this.scrollToBottom(); }
|
if (follow) { this.scrollToBottom(); }
|
||||||
|
// Re-show the container (we hid it before rendering to avoid jump-to-top)
|
||||||
|
try {
|
||||||
|
if (container && container.dataset && container.dataset.renderHidden) {
|
||||||
|
container.style.visibility = 'visible';
|
||||||
|
delete container.dataset.renderHidden;
|
||||||
|
}
|
||||||
|
} catch(e) { /* ignore */ }
|
||||||
} else if (container) {
|
} else if (container) {
|
||||||
// Mantener posición: desplazar por la diferencia de heights
|
// Mantener posición: desplazar por la diferencia de heights
|
||||||
const newScrollHeight = container.scrollHeight;
|
const newScrollHeight = container.scrollHeight;
|
||||||
@@ -3005,6 +3014,9 @@
|
|||||||
} else {
|
} else {
|
||||||
// En cargas iniciales mostramos el mensaje de error y botón de reintento (comportamiento previo)
|
// En cargas iniciales mostramos el mensaje de error y botón de reintento (comportamiento previo)
|
||||||
if (container) {
|
if (container) {
|
||||||
|
// Make sure it's visible again
|
||||||
|
try { if (container && container.dataset && container.dataset.renderHidden) { container.style.visibility = 'visible'; delete container.dataset.renderHidden; } } catch(e) {}
|
||||||
|
|
||||||
container.innerHTML = `
|
container.innerHTML = `
|
||||||
<div class="text-center p-4">
|
<div class="text-center p-4">
|
||||||
<i class="fas fa-exclamation-triangle text-warning fa-2x"></i>
|
<i class="fas fa-exclamation-triangle text-warning fa-2x"></i>
|
||||||
@@ -3040,6 +3052,8 @@
|
|||||||
} catch (e) { console.warn('Failed to trim empty messages before render', e); }
|
} catch (e) { console.warn('Failed to trim empty messages before render', e); }
|
||||||
|
|
||||||
if (initial) {
|
if (initial) {
|
||||||
|
// Hide the container while we rebuild the DOM to avoid a visible jump to the top
|
||||||
|
try { container.style.visibility = 'hidden'; container.dataset.renderHidden = '1'; } catch(e) {}
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user