fix: eliminar polling get_last_webhook_time (innecesario en index.php)
This commit is contained in:
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user