Clearing a notification settles what it was about; fix missed phone pushes
build-container / build (push) Successful in 3m2s

Reading or clearing a notification marks its chat and new mail read and closes its banner; opening a chat clears its entry. Close the chat stream while the app is hidden so the server sends the phone push, renew changed push subscriptions, and re-send the subscription on each app open.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 5.5 committed 2026-10-27 08:55:49 -04:00
1 parent 41c48b10e8
commit a09d6b17f4
9 files changed
+82 -21

No files matched your search

+9 -1
View File
@@ -1,5 +1,5 @@
// App-shell cache only; Seafile/API traffic always goes to the network.
const CACHE = 'hub-v89';
const CACHE = 'hub-v90';
const SHARE = 'hub-share'; // files shared into the app from other apps, held until the person picks a folder
const SHELL = ['/icon.svg', '/manifest.webmanifest', '/icons/icon-192.png', '/icons/apple-touch-icon.png'];
@@ -59,6 +59,14 @@ self.addEventListener('push', e => {
let d = {}; try { d = e.data.json(); } catch {}
e.waitUntil(self.registration.showNotification(d.title || 'NE Hub', { body: d.body || '', icon: '/icons/icon-192.png', badge: '/icons/icon-192.png', tag: d.tag, data: { url: d.url || '#/home' } }));
});
// The push service can replace a device's subscription: make a new one and give it to the server so reminders keep arriving.
self.addEventListener('pushsubscriptionchange', e => e.waitUntil((async () => {
try {
const k = await (await fetch('/api/push/key', { credentials: 'same-origin' })).json();
const s = await self.registration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: k.publicKey });
await fetch('/api/push/subscribe', { method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ subscription: s.toJSON() }) });
} catch { /* signed out or offline: the app re-registers when it is next opened */ }
})()));
self.addEventListener('notificationclick', e => {
e.notification.close();
const url = '/' + ((e.notification.data && e.notification.data.url) || '');