This commit is contained in:
Lizandro Guarnizo
2026-01-28 03:24:00 -05:00
parent e96f507a06
commit ee3524a54b
2 changed files with 49 additions and 8 deletions
+30 -8
View File
@@ -889,6 +889,8 @@ if (!isset($_SESSION['user_id'])) {
<div id="bot-toggle-container" style="display:flex;align-items:center;gap:6px;margin-right:8px;">
<button class="btn btn-sm btn-outline-secondary" id="bot-toggle">Bot: On</button>
</div>
<!-- Botón actualizar mensajes -->
<button class="btn btn-sm btn-outline-light" id="refresh-messages-btn" title="Actualizar mensajes"><i class="fas fa-sync-alt"></i></button>
<!-- PWA install button for conversations view -->
<button id="pwa-install-btn" class="btn btn-sm btn-outline-primary d-none" style="display:none;">Instalar</button>
<button class="btn btn-sm btn-outline-secondary" id="mark-unread-btn" title="Marcar conversación como no leída" style="display:none;">Marcar no leído</button>
@@ -1774,6 +1776,25 @@ if (!isset($_SESSION['user_id'])) {
this.sendMessage();
});
// Botón actualizar mensajes
const refreshBtn = document.getElementById('refresh-messages-btn');
if (refreshBtn) {
refreshBtn.addEventListener('click', async () => {
if (!this.currentUserId) return;
refreshBtn.disabled = true;
refreshBtn.innerHTML = '<i class="fas fa-sync-alt fa-spin"></i>';
try {
await this.loadMessages(this.currentUserId, true, true);
console.log('✅ Mensajes actualizados manualmente');
} catch (e) {
console.error('Error actualizando mensajes:', e);
} finally {
refreshBtn.disabled = false;
refreshBtn.innerHTML = '<i class="fas fa-sync-alt"></i>';
}
});
}
// Forward handler: open preview when user chooses to forward an existing message
this.forwardMessage = function(messageId) {
try {
@@ -2778,10 +2799,16 @@ if (!isset($_SESSION['user_id'])) {
}
const json = await resp.json();
if (json && json.success) {
// SSE actualizará las conversaciones automáticamente
// await this.loadConversations();
alert('Conversación marcada como NO leída.');
// Actualizar la conversación local para mostrar badge de no leído
const conv = this.conversations.find(c => String(c.user_id) === String(userId));
if (conv) {
conv.unread_count = Math.max(1, conv.unread_count || 1);
}
// Refrescar la lista visual
this.renderConversations();
console.log('✅ Conversación marcada como no leída');
} else {
console.error('Error marcando conversación como no leída:', json);
alert('Error marcando conversación como no leída');
}
} catch (e) {
@@ -5246,10 +5273,5 @@ if (!isset($_SESSION['user_id'])) {
</div>
</div>
<!-- Footer U-Site -->
<footer style="position: fixed; bottom: 0; left: 0; right: 0; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); padding: 8px 20px; text-align: center; font-size: 12px; color: rgba(255,255,255,0.7); z-index: 999; border-top: 1px solid rgba(255,255,255,0.1);">
Desarrollado con 💚 por <a href="https://u-site.app" target="_blank" style="color: #25d366; text-decoration: none; font-weight: 600;">U-Site.app</a>
</footer>
</body>
</html>