diff --git a/chat_window.php b/chat_window.php index e6f6d04..129aa39 100644 --- a/chat_window.php +++ b/chat_window.php @@ -1030,10 +1030,9 @@ if (empty($user_id)) { } }); - // Mostrar contenedor solo si hay respuestas - if (container.children.length) { - wrapper.style.display = 'block'; - } else { + // No mostrar automáticamente el contenedor al cargar la conversación. + // Dejamos que el usuario lo abra con el botón toggle. Si no hay respuestas, mantener oculto. + if (!container.children.length) { wrapper.style.display = 'none'; } } else { @@ -1046,8 +1045,20 @@ if (empty($user_id)) { function toggleQuickReplies() { const wrapper = document.getElementById('quickRepliesContainer'); + const container = document.getElementById('quickRepliesButtons'); if (!wrapper) return; - wrapper.style.display = (wrapper.style.display === 'block') ? 'none' : 'block'; + + // Si no hay botones cargados, intentar cargarlos y luego mostrar + if (container && container.children.length === 0) { + loadQuickReplies().then(() => { + wrapper.style.display = (wrapper.style.display === 'block') ? 'none' : 'block'; + }).catch(() => { + // on error, mantener oculto + wrapper.style.display = 'none'; + }); + } else { + wrapper.style.display = (wrapper.style.display === 'block') ? 'none' : 'block'; + } } function showError(message) {