refactor(sw): self => globalThis

This commit is contained in:
tamaina
2023-02-18 05:16:34 +00:00
parent 0f546b47d1
commit 36170a11f5
3 changed files with 13 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ import * as swos from '@/scripts/operations';
import { acct as getAcct } from '@/filters/user';
globalThis.addEventListener('install', ev => {
//ev.waitUntil(self.skipWaiting());
//ev.waitUntil(globalThis.skipWaiting());
});
globalThis.addEventListener('activate', ev => {
@@ -17,7 +17,7 @@ globalThis.addEventListener('activate', ev => {
.filter((v) => v !== swLang.cacheName)
.map(name => caches.delete(name)),
))
.then(() => self.clients.claim()),
.then(() => globalThis.clients.claim()),
);
});
@@ -40,7 +40,7 @@ globalThis.addEventListener('fetch', ev => {
globalThis.addEventListener('push', ev => {
// クライアント取得
ev.waitUntil(self.clients.matchAll({
ev.waitUntil(globalThis.clients.matchAll({
includeUncontrolled: true,
type: 'window',
}).then(async (clients: readonly WindowClient[]) => {
@@ -58,24 +58,24 @@ globalThis.addEventListener('push', ev => {
return createNotification(data);
case 'readAllNotifications':
for (const n of await self.registration.getNotifications()) {
for (const n of await globalThis.registration.getNotifications()) {
if (n?.data?.type === 'notification') n.close();
}
break;
case 'readAllAntennas':
for (const n of await self.registration.getNotifications()) {
for (const n of await globalThis.registration.getNotifications()) {
if (n?.data?.type === 'unreadAntennaNote') n.close();
}
break;
case 'readNotifications':
for (const n of await self.registration.getNotifications()) {
for (const n of await globalThis.registration.getNotifications()) {
if (data.body.notificationIds.includes(n.data.body.id)) {
n.close();
}
}
break;
case 'readAntenna':
for (const n of await self.registration.getNotifications()) {
for (const n of await globalThis.registration.getNotifications()) {
if (n?.data?.type === 'unreadAntennaNote' && data.body.antennaId === n.data.body.antenna.id) {
n.close();
}