From 46a9d97a0729e5bae54752f0d8de9796375bc80e Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 13 Mar 2026 18:47:21 -0500 Subject: [PATCH] fix: eliminar polling get_last_webhook_time (innecesario en index.php) --- assets/js/app_simple.js | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/assets/js/app_simple.js b/assets/js/app_simple.js index b95b1cf..2ce2e54 100644 --- a/assets/js/app_simple.js +++ b/assets/js/app_simple.js @@ -9,10 +9,6 @@ class SimpleWhatsAppManager { this.currentTab = 'dashboard'; this.init(); - - // Webhook polling state - this._lastWebhook = null; - this.setupWebhookPolling(); } init() { @@ -174,40 +170,7 @@ class SimpleWhatsAppManager { } } - // Polling ligero para detectar nuevos webhooks y refrescar UI rĂ¡pidamente - setupWebhookPolling() { - // Ejecutar cada 5 segundos - setInterval(async () => { - try { - const res = await fetch(this.apiBaseUrl + 'get_last_webhook_time.php'); - if (!res.ok) return; - const data = await res.json(); - if (!data || !data.success) return; - const last = data.last_webhook; - if (!last) return; - - if (this._lastWebhook && this._lastWebhook === last) return; - - // Hubo un nuevo webhook - this._lastWebhook = last; - this.log('Nuevo webhook detectado, refrescando conversaciones', 'info'); - - // Refrescar lista de conversaciones - await this.loadUsers(); // reload users (optional) - await this.loadconversations(); // reload message-related selects if on send_message - await this.loadConversations(); - - // Si hay un chat abierto, recargar sus mensajes - if (this.currentTab === 'conversations' && this.currentUserId) { - await this.loadconversations(this.currentUserId, false); - } - - } catch (e) { - this.log('Error polling webhook: ' + e.message, 'error'); - } - }, 5000); - } async apiCallReal(endpoint, options = {}) { const url = `${this.apiBaseUrl}${endpoint}`;