Update conversations.php
This commit is contained in:
+25
-2
@@ -665,6 +665,29 @@
|
||||
<?php $asset_v = file_exists(__DIR__ . '/assets/js/chat-common.js') ? filemtime(__DIR__ . '/assets/js/chat-common.js') : time(); ?>
|
||||
<script src="assets/js/chat-common.js?v=<?php echo $asset_v; ?>"></script>
|
||||
<script>
|
||||
// Fallback ligero para showAlert (si no existe una implementación global)
|
||||
if (typeof showAlert === 'undefined') {
|
||||
function showAlert(message, type = 'info') {
|
||||
try {
|
||||
let container = document.getElementById('notification-toasts');
|
||||
if (!container) {
|
||||
container = document.createElement('div');
|
||||
container.id = 'notification-toasts';
|
||||
document.body.appendChild(container);
|
||||
}
|
||||
const toast = document.createElement('div');
|
||||
toast.className = 'notification-toast small' + (type === 'success' ? ' cool' : '');
|
||||
const icon = type === 'success' ? '✅' : (type === 'danger' ? '⚠️' : (type === 'warning' ? '⚠' : 'ℹ️'));
|
||||
toast.innerHTML = `<span class="nt-icon">${icon}</span><div style="flex:1; font-size:13px">${message}</div>`;
|
||||
container.appendChild(toast);
|
||||
setTimeout(() => { if (toast.parentNode) toast.remove(); }, type === 'success' ? 4000 : 8000);
|
||||
} catch (e) {
|
||||
// fallback to alert if DOM fails
|
||||
try { alert(message); } catch (e2) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WhatsAppChat {
|
||||
constructor() {
|
||||
this.currentConversationId = null;
|
||||
@@ -1716,7 +1739,7 @@
|
||||
this.hideReplyPreview();
|
||||
if (resp && resp.success) {
|
||||
this.addMessageToView(`Plantilla: ${templateName}`, 'outgoing');
|
||||
showAlert && showAlert('Mensaje de plantilla enviado correctamente', 'success');
|
||||
typeof showAlert !== 'undefined' && showAlert('Mensaje de plantilla enviado correctamente', 'success');
|
||||
await this.loadconversations(this.currentUserId, false);
|
||||
await this.loadConversations();
|
||||
} else {
|
||||
@@ -1845,7 +1868,7 @@
|
||||
input.value = '';
|
||||
// Mostrar inmediatamente en la vista
|
||||
this.addMessageToView(message, 'outgoing');
|
||||
showAlert && showAlert('Mensaje enviado correctamente', 'success');
|
||||
typeof showAlert !== 'undefined' && showAlert('Mensaje enviado correctamente', 'success');
|
||||
// Recargar mensajes y conversaciones en background
|
||||
this.loadconversations(this.currentUserId, false).catch(e=>console.warn(e));
|
||||
this.loadConversations().catch(e=>console.warn(e));
|
||||
|
||||
Reference in New Issue
Block a user