aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-07-29 10:18:54 +0300
committerGravatar Vitaly Takmazov2024-07-29 10:18:54 +0300
commitf9b063ece0b321c4652533dd570065dc841b9a81 (patch)
treead1759c73d760c93bcc43b83ca2806abe668ece5 /src/main/resources
parent4fc0b2baec174e8ccb98f88a16d012668845e49e (diff)
Bundle service worker correctly
Diffstat (limited to 'src/main/resources')
-rw-r--r--src/main/resources/static/sw.js47
1 files changed, 0 insertions, 47 deletions
diff --git a/src/main/resources/static/sw.js b/src/main/resources/static/sw.js
deleted file mode 100644
index a64de7cc..00000000
--- a/src/main/resources/static/sw.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/// <reference no-default-lib="true"/>
-/// <reference lib="esnext" />
-/// <reference lib="WebWorker" />
-
-var sw = /** @type {ServiceWorkerGlobalScope & typeof self} */ (self)
-sw.addEventListener('install', function() {
- sw.skipWaiting()
-})
-sw.addEventListener('activate', function() {
- sw.clients.claim()
-})
-sw.addEventListener('push', function(evt) {
- if (evt.data) {
- const data = evt.data.json()
- console.log('Push', data)
- if (data.body) {
- sw.registration.showNotification(data.title, {
- body: data.body,
- icon: data.custom.message.user.avatar,
- tag: data.tag,
- data: data.custom.message
- })
- }
- }
-})
-sw.addEventListener('notificationclick', function(evt) {
- evt.waitUntil(
- sw.clients.matchAll().then(function(clientList) {
- const message = evt.notification.data
- const url = message.mid
- ? message.rid
- ? `https://juick.com/m/${message.mid}#${message.rid}`
- : `https://juick.com/m/${message.mid}`
- : 'https://juick.com/pm/inbox'
- if (clientList.length > 0) {
- for (var i = 0; i < clientList.length; i++) {
- if (clientList[i].url === url) {
- return clientList[i].focus()
- }
- }
- clientList[0].navigate(url)
- return clientList[0].focus()
- }
- return sw.clients.openWindow(url)
- })
- )
-})