This commit is contained in:
Lizandro Guarnizo
2026-01-27 15:01:32 -05:00
parent 1f224044f7
commit 6e3f375f91
3 changed files with 30 additions and 12 deletions
+15 -7
View File
@@ -1055,12 +1055,18 @@
}
setupNotificationPolling() {
// Carga inicial de notificaciones pendientes
// Carga inicial de notificaciones pendientes (opcional)
// SSE se encargará de las nuevas en tiempo real
this.loadNotifications();
this.loadNotifications().catch(e => {
console.debug('Carga inicial de notificaciones omitida (SSE activo):', e.message);
});
// Backup: verificar cada 60 segundos (solo por si SSE falla)
setInterval(() => this.loadNotifications(), 60000);
setInterval(() => {
this.loadNotifications().catch(e => {
console.debug('Polling de notificaciones omitido (SSE activo)');
});
}, 60000);
}
/**
@@ -1294,12 +1300,13 @@
const resp = await fetch('api/get_notifications.php', { credentials: 'same-origin' });
if (!resp.ok) {
console.warn(`Notifications fetch: HTTP ${resp.status} ${resp.statusText}`);
// Si falla, no es problema: SSE manejará las notificaciones en tiempo real
console.debug(`Notifications fetch: HTTP ${resp.status} (SSE manejará las notificaciones)`);
return;
}
if (resp.status === 401) {
console.warn('Notifications fetch: unauthorized (session may have expired)');
console.debug('Notifications fetch: unauthorized (SSE manejará las notificaciones)');
return;
}
@@ -1308,10 +1315,11 @@
if (json && json.success && Array.isArray(json.data)) {
json.data.forEach(n => this.showNotificationToast(n));
} else if (json && json.success === false) {
console.warn('get_notifications returned error:', json.error || json);
console.debug('get_notifications returned error (no crítico, SSE activo):', json.error || json);
}
} catch (e) {
console.error('Error loading notifications', e);
// Error no crítico: SSE manejará las notificaciones en tiempo real
console.debug('loadNotifications failed (SSE manejará las notificaciones):', e.message);
}
}