Compare commits
21 Commits
master
...
home-view-
Author | SHA1 | Date |
---|---|---|
Matthew Raymer | 2b8cd180a1 | 1 year ago |
Matthew Raymer | abc4a93b34 | 1 year ago |
Matthew Raymer | 36493920f3 | 1 year ago |
Matthew Raymer | 96fd4f68ef | 1 year ago |
Matthew Raymer | fc37f475d5 | 1 year ago |
Matthew Raymer | 80b7ab2f82 | 1 year ago |
Matthew Raymer | 5f2658fd01 | 1 year ago |
Matthew Raymer | 267ed40946 | 1 year ago |
Matthew Raymer | 1ce9e788e9 | 1 year ago |
Matthew Raymer | fe7b30ee32 | 1 year ago |
Matthew Raymer | ad3cb10722 | 1 year ago |
Matthew Raymer | d6dc7fbb10 | 1 year ago |
Matthew Raymer | cf2fec75ea | 1 year ago |
Matthew Raymer | 9216be523a | 1 year ago |
Matthew Raymer | 7ab3cb2d1f | 1 year ago |
Matthew Raymer | aba0d832db | 1 year ago |
Matthew Raymer | 7906aab36e | 1 year ago |
Matthew Raymer | 9b3d2b4c52 | 1 year ago |
Matthew Raymer | ceb12ef5bc | 1 year ago |
Matthew Raymer | 805c7b4810 | 1 year ago |
Jose Olarte III | c344d37bd9 | 1 year ago |
13 changed files with 10188 additions and 5269 deletions
@ -1,33 +1,63 @@ |
|||||
const notifications = require("./safari-notifications.js"); |
/* eslint-env serviceworker */ |
||||
|
/* global workbox */ |
||||
|
importScripts( |
||||
|
"https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js", |
||||
|
); |
||||
|
|
||||
|
self.addEventListener("install", (event) => { |
||||
|
importScripts( |
||||
|
"safari-notifications.js", |
||||
|
"nacl.js", |
||||
|
"noble-curves.js", |
||||
|
"noble-hashes.js", |
||||
|
); |
||||
|
}); |
||||
|
|
||||
self.addEventListener("push", function (event) { |
self.addEventListener("push", function (event) { |
||||
|
event.waitUntil( |
||||
|
(async () => { |
||||
|
try { |
||||
let payload; |
let payload; |
||||
if (event.data) { |
if (event.data) { |
||||
payload = JSON.parse(event.data.text()); |
payload = JSON.parse(event.data.text()); |
||||
} |
} |
||||
|
const message = await self.getNotificationCount(); |
||||
const title = payload ? payload.title : "Custom Title"; |
const title = payload ? payload.title : "Custom Title"; |
||||
const options = { |
const options = { |
||||
body: payload ? payload.body : "Custom body text", |
body: message, |
||||
icon: payload ? payload.icon : "icon.png", |
icon: payload ? payload.icon : "icon.png", |
||||
badge: payload ? payload.badge : "badge.png", |
badge: payload ? payload.badge : "badge.png", |
||||
}; |
}; |
||||
|
await self.registration.showNotification(title, options); |
||||
event.waitUntil(self.registration.showNotification(title, options)); |
} catch (error) { |
||||
|
console.error("Error in processing the push event:", error); |
||||
|
} |
||||
|
})(), |
||||
|
); |
||||
}); |
}); |
||||
|
|
||||
|
self.addEventListener("message", (event) => { |
||||
|
if (event.data && event.data.type === "SEND_LOCAL_DATA") { |
||||
|
self.secret = event.data.data; |
||||
|
event.ports[0].postMessage({ success: true }); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
self.addEventListener("message", function (event) { |
self.addEventListener("activate", (event) => { |
||||
const data = event.data; |
event.waitUntil(clients.claim()); |
||||
|
console.log("Service worker activated", event); |
||||
const result = notifications.getNotificationCount() |
}); |
||||
|
|
||||
switch (data.command) { |
self.addEventListener("fetch", (event) => { |
||||
case "account": |
console.log(event.request); |
||||
break; |
}); |
||||
|
|
||||
default: |
self.addEventListener("error", (event) => { |
||||
console.log("Unknown command:", data.command); |
console.error("Error in Service Worker:", event.message); |
||||
} |
console.error("File:", event.filename); |
||||
|
console.error("Line:", event.lineno); |
||||
|
console.error("Column:", event.colno); |
||||
|
console.error("Error Object:", event.error); |
||||
}); |
}); |
||||
|
|
||||
|
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST); |
||||
|
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
Loading…
Reference in new issue