fix: read receipts (single/double check), push notifications for all users

- Track when others read messages via messages_read WS event
- Show Check (single) for sent, CheckCheck (double) only when read
- Send push to all recipients, SW suppresses if app is focused

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ai
2026-05-22 13:47:38 +03:00
parent 86073c0549
commit 20daa2ca2f
6 changed files with 31 additions and 16 deletions

View File

@@ -29,12 +29,17 @@ self.addEventListener('push', (event) => {
try { data = event.data.json(); } catch {}
event.waitUntil(
self.registration.showNotification(data.title, {
body: data.body,
icon: '/icon-192.png',
badge: '/icon-192.png',
data: { chatId: data.chatId },
vibrate: [200, 100, 200],
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(clients => {
// Suppress if any app window is focused
const appFocused = clients.some(c => c.focused);
if (appFocused) return;
return self.registration.showNotification(data.title, {
body: data.body,
icon: '/icon-192.png',
badge: '/icon-192.png',
data: { chatId: data.chatId },
vibrate: [200, 100, 200],
});
})
);
});