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:
@@ -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],
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user