up
This commit is contained in:
+14
-7
@@ -24,6 +24,9 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||||
|
<meta http-equiv="Pragma" content="no-cache">
|
||||||
|
<meta http-equiv="Expires" content="0">
|
||||||
<title>💬 Conversaciones - WhatsApp Bot</title>
|
<title>💬 Conversaciones - WhatsApp Bot</title>
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
||||||
@@ -1862,7 +1865,7 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
const mid = this._pendingReactionMessage;
|
const mid = this._pendingReactionMessage;
|
||||||
if (!mid) return;
|
if (!mid) return;
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('api/react_message.php', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify({ message_id: mid, emoji: emoji }) });
|
const resp = await fetch('api/react_message.php', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify({ message_id: mid, emoji: emoji }), cache: 'no-store' });
|
||||||
const j = await resp.json();
|
const j = await resp.json();
|
||||||
if (j && j.success) {
|
if (j && j.success) {
|
||||||
// update local model and UI
|
// update local model and UI
|
||||||
@@ -2459,7 +2462,7 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
if (loadMoreBtn) loadMoreBtn.disabled = true;
|
if (loadMoreBtn) loadMoreBtn.disabled = true;
|
||||||
try {
|
try {
|
||||||
const url = `api/get_conversations.php?page=${page}&limit=${this.conversationsLimit}&filter=${encodeURIComponent(this.conversationFilter)}`;
|
const url = `api/get_conversations.php?page=${page}&limit=${this.conversationsLimit}&filter=${encodeURIComponent(this.conversationFilter)}`;
|
||||||
const resp = await fetch(url, { credentials: 'same-origin' });
|
const resp = await fetch(url, { credentials: 'same-origin', cache: 'no-store' });
|
||||||
|
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
throw new Error(`HTTP ${resp.status}: ${resp.statusText}`);
|
throw new Error(`HTTP ${resp.status}: ${resp.statusText}`);
|
||||||
@@ -2789,7 +2792,8 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
const resp = await fetch('api/mark_conversation_unread.php', {
|
const resp = await fetch('api/mark_conversation_unread.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ user_id: userId })
|
body: JSON.stringify({ user_id: userId }),
|
||||||
|
cache: 'no-store'
|
||||||
});
|
});
|
||||||
if (resp.status === 401) {
|
if (resp.status === 401) {
|
||||||
alert('Sesión expirada. Por favor inicie sesión de nuevo.');
|
alert('Sesión expirada. Por favor inicie sesión de nuevo.');
|
||||||
@@ -2840,7 +2844,8 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
const resp = await fetch('api/release_hold.php', {
|
const resp = await fetch('api/release_hold.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ user_id: userId })
|
body: JSON.stringify({ user_id: userId }),
|
||||||
|
cache: 'no-store'
|
||||||
});
|
});
|
||||||
if (resp.status === 401) {
|
if (resp.status === 401) {
|
||||||
alert('Sesión expirada. Por favor inicie sesión de nuevo.');
|
alert('Sesión expirada. Por favor inicie sesión de nuevo.');
|
||||||
@@ -4554,7 +4559,7 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
if (!msg) {
|
if (!msg) {
|
||||||
// intentar obtener mensaje por API
|
// intentar obtener mensaje por API
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(`api/get_message.php?message_id=${encodeURIComponent(messageId)}`);
|
const resp = await fetch(`api/get_message.php?message_id=${encodeURIComponent(messageId)}`, { cache: 'no-store' });
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
const j = await resp.json();
|
const j = await resp.json();
|
||||||
if (j && j.success && j.data) {
|
if (j && j.success && j.data) {
|
||||||
@@ -4695,7 +4700,8 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
const resp = await fetch('api/update_user.php', {
|
const resp = await fetch('api/update_user.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ user_id: this.currentUserId, name: newName })
|
body: JSON.stringify({ user_id: this.currentUserId, name: newName }),
|
||||||
|
cache: 'no-store'
|
||||||
});
|
});
|
||||||
const json = await resp.json();
|
const json = await resp.json();
|
||||||
if (json && json.success) {
|
if (json && json.success) {
|
||||||
@@ -4717,7 +4723,8 @@ if (!isset($_SESSION['user_id'])) {
|
|||||||
const resp = await fetch('api/delete_conversation.php', {
|
const resp = await fetch('api/delete_conversation.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ user_id: this.currentUserId })
|
body: JSON.stringify({ user_id: this.currentUserId }),
|
||||||
|
cache: 'no-store'
|
||||||
});
|
});
|
||||||
const json = await resp.json();
|
const json = await resp.json();
|
||||||
if (json && json.success) {
|
if (json && json.success) {
|
||||||
|
|||||||
+35
-3
@@ -1,11 +1,43 @@
|
|||||||
// Minimal service worker stub to avoid 404s during development.
|
// Service worker - Force no-cache for API requests
|
||||||
|
const CACHE_VERSION = 'v1.0.1';
|
||||||
|
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event) => {
|
||||||
// activate immediately
|
// activate immediately
|
||||||
self.skipWaiting();
|
self.skipWaiting();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('activate', (event) => {
|
self.addEventListener('activate', (event) => {
|
||||||
event.waitUntil(self.clients.claim());
|
event.waitUntil(
|
||||||
|
caches.keys().then(keys => {
|
||||||
|
// Clear all caches on activation
|
||||||
|
return Promise.all(keys.map(key => caches.delete(key)));
|
||||||
|
}).then(() => self.clients.claim())
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('fetch', (event) => {
|
self.addEventListener('fetch', (event) => {
|
||||||
// No-op: default network behaviour
|
const url = new URL(event.request.url);
|
||||||
|
|
||||||
|
// For API requests, always go to network with no-cache
|
||||||
|
if (url.pathname.startsWith('/api/') || url.pathname.includes('/api/')) {
|
||||||
|
event.respondWith(
|
||||||
|
fetch(event.request, {
|
||||||
|
cache: 'no-store',
|
||||||
|
headers: {
|
||||||
|
...Object.fromEntries(event.request.headers),
|
||||||
|
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||||
|
'Pragma': 'no-cache'
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('SW fetch error:', err);
|
||||||
|
return new Response(JSON.stringify({ error: 'Network error' }), {
|
||||||
|
status: 503,
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For other requests, use default network behavior (no caching)
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user