feat(web): service-worker notifications and composer/scroll UX fixes
Some checks failed
CI / test (push) Failing after 21s
Some checks failed
CI / test (push) Failing after 21s
- register notifications service worker and handle click-to-open chat/message - route realtime notifications through service worker with fallback - support ?chat=&message= deep-link navigation in chats page - enforce 1s minimum voice message length - lift scroll-to-bottom button to avoid overlap with composer action
This commit is contained in:
33
web/public/notifications-sw.js
Normal file
33
web/public/notifications-sw.js
Normal file
@@ -0,0 +1,33 @@
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(self.skipWaiting());
|
||||
});
|
||||
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(self.clients.claim());
|
||||
});
|
||||
|
||||
self.addEventListener("notificationclick", (event) => {
|
||||
event.notification.close();
|
||||
const data = event.notification.data || {};
|
||||
const targetPath = typeof data.url === "string" ? data.url : "/";
|
||||
const targetUrl = new URL(targetPath, self.location.origin).toString();
|
||||
|
||||
event.waitUntil(
|
||||
self.clients.matchAll({ type: "window", includeUncontrolled: true }).then(async (clientList) => {
|
||||
if (clientList.length > 0) {
|
||||
const client = clientList[0];
|
||||
if ("navigate" in client) {
|
||||
await client.navigate(targetUrl);
|
||||
}
|
||||
if ("focus" in client) {
|
||||
await client.focus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (self.clients.openWindow) {
|
||||
await self.clients.openWindow(targetUrl);
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user