aboutsummaryrefslogtreecommitdiffstats
path: root/src/service-worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/service-worker.js')
-rw-r--r--src/service-worker.js58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/service-worker.js b/src/service-worker.js
index fa934333..383f62d0 100644
--- a/src/service-worker.js
+++ b/src/service-worker.js
@@ -1,37 +1,35 @@
-import { build, files, version } from "$service-worker";
-
-self.addEventListener("install", (event) => {});
-self.addEventListener("activate", (event) => {});
-self.addEventListener("fetch", (event) => {});
+self.addEventListener("install", () => {});
+self.addEventListener("activate", () => {});
+self.addEventListener("fetch", () => {});
self.addEventListener("push", (event) => {
- const { title, body, url } = event.data.json();
- const icon = "/images/icon.png";
- const badge = "/images/badge.png";
- self.registration.showNotification(title, {
- body,
- icon,
- badge,
- data: { url },
- });
+ const { title, body, url } = event.data.json();
+ const icon = "/images/icon.png";
+ const badge = "/images/badge.png";
+ self.registration.showNotification(title, {
+ body,
+ icon,
+ badge,
+ data: { url },
+ });
});
self.addEventListener("notificationclick", (event) => {
- event.notification.close();
+ event.notification.close();
- const url = event.notification.data.url || "/";
+ const url = event.notification.data.url || "/";
- event.waitUntil(
- clients
- .matchAll({ type: "window", includeUncontrolled: true })
- .then((clientList) => {
- for (const client of clientList) {
- if (client.url === url && "focus" in client) {
- return client.focus();
- }
- }
- if (clients.openWindow) {
- return clients.openWindow(url);
- }
- }),
- );
+ event.waitUntil(
+ clients
+ .matchAll({ type: "window", includeUncontrolled: true })
+ .then((clientList) => {
+ for (const client of clientList) {
+ if (client.url === url && "focus" in client) {
+ return client.focus();
+ }
+ }
+ if (clients.openWindow) {
+ return clients.openWindow(url);
+ }
+ }),
+ );
});