Scheduling infrastructure for absolutely everyone.
perf: service worker lifecycle method (#21532)
Udit Takkare5868837d53b
diff --git a/apps/web/components/notification-sound-handler.tsx b/apps/web/components/notification-sound-handler.tsxindex 8a57daa552c..47304396873 100644--- a/apps/web/components/notification-sound-handler.tsx+++ b/apps/web/components/notification-sound-handler.tsx@@ -91,6 +91,11 @@ export function NotificationSoundHandler() {// Don't automatically initialize - wait for user interactionreturn () => {stopSound();+ if (audioContextRef.current && audioContextRef.current.state !== "closed") {+ audioContextRef.current.close();+ }+ audioContextRef.current = null;+ audioBufferRef.current = null;};}, []);diff --git a/apps/web/public/service-worker.js b/apps/web/public/service-worker.jsindex 4d3759d8581..81e62f0f080 100644--- a/apps/web/public/service-worker.js+++ b/apps/web/public/service-worker.js@@ -25,18 +25,7 @@ self.addEventListener("push", async (event) => {});existingNotifications.forEach((notification) => {- const options = {- body: notification.body,- icon: notification.icon,- badge: notification.badge,- data: notification.data,- silent: notification.silent,- vibrate: notification.vibrate,- requireInteraction: notification.requireInteraction,- tag: notification.tag,- };-- self.registration.showNotification(notification.title, options);+ notification.close();});// Special handling for instant meetings@@ -87,6 +76,8 @@ self.addEventListener("notificationclick", (event) => {});});};++ event.waitUntil(stopSound());}if (!event.action) {@@ -111,4 +102,13 @@ self.addEventListener('install', (event) => {self.addEventListener('activate', (event) => {console.log('Service Worker activated.');++ event.waitUntil(+ (async () => {+ const notifications = await self.registration.getNotifications();+ notifications.forEach(notification => notification.close());++ return self.clients.claim();+ })()+ );});