drop messaging (#9919)

* drop messaging (from backend)

* wip
This commit is contained in:
syuilo
2023-02-15 13:06:06 +09:00
committed by GitHub
parent d0aba46ee3
commit 8f2049bcd2
47 changed files with 18 additions and 3292 deletions

View File

@@ -15,9 +15,9 @@ globalThis.addEventListener('activate', ev => {
.then(cacheNames => Promise.all(
cacheNames
.filter((v) => v !== swLang.cacheName)
.map(name => caches.delete(name))
.map(name => caches.delete(name)),
))
.then(() => self.clients.claim())
.then(() => self.clients.claim()),
);
});
@@ -34,7 +34,7 @@ globalThis.addEventListener('fetch', ev => {
if (!isHTMLRequest) return;
ev.respondWith(
fetch(ev.request)
.catch(() => new Response(`Offline. Service Worker @${_VERSION_}`, { status: 200 }))
.catch(() => new Response(`Offline. Service Worker @${_VERSION_}`, { status: 200 })),
);
});
@@ -42,14 +42,13 @@ globalThis.addEventListener('push', ev => {
// クライアント取得
ev.waitUntil(self.clients.matchAll({
includeUncontrolled: true,
type: 'window'
type: 'window',
}).then(async (clients: readonly WindowClient[]) => {
const data: pushNotificationDataMap[keyof pushNotificationDataMap] = ev.data?.json();
switch (data.type) {
// case 'driveFileCreated':
case 'notification':
case 'unreadMessagingMessage':
case 'unreadAntennaNote':
// 1日以上経過している場合は無視
if ((new Date()).getTime() - data.dateTime > 1000 * 60 * 60 * 24) break;
@@ -63,11 +62,6 @@ globalThis.addEventListener('push', ev => {
if (n?.data?.type === 'notification') n.close();
}
break;
case 'readAllMessagingMessages':
for (const n of await self.registration.getNotifications()) {
if (n?.data?.type === 'unreadMessagingMessage') n.close();
}
break;
case 'readAllAntennas':
for (const n of await self.registration.getNotifications()) {
if (n?.data?.type === 'unreadAntennaNote') n.close();
@@ -75,25 +69,14 @@ globalThis.addEventListener('push', ev => {
break;
case 'readNotifications':
for (const n of await self.registration.getNotifications()) {
if (data.body?.notificationIds?.includes(n.data.body.id)) {
if (data.body.notificationIds.includes(n.data.body.id)) {
n.close();
}
}
break;
case 'readAllMessagingMessagesOfARoom':
for (const n of await self.registration.getNotifications()) {
if (n.data.type === 'unreadMessagingMessage'
&& ('userId' in data.body
? data.body.userId === n.data.body.userId
: data.body.groupId === n.data.body.groupId)
) {
n.close();
}
}
break;
case 'readAntenna':
for (const n of await self.registration.getNotifications()) {
if (n?.data?.type === 'unreadAntennaNote' && data.body?.antennaId === n.data.body.antenna.id) {
if (n?.data?.type === 'unreadAntennaNote' && data.body.antennaId === n.data.body.antenna.id) {
n.close();
}
}
@@ -174,9 +157,6 @@ globalThis.addEventListener('notificationclick', (ev: ServiceWorkerGlobalScopeEv
}
}
break;
case 'unreadMessagingMessage':
client = await swos.openChat(data.body, loginId);
break;
case 'unreadAntennaNote':
client = await swos.openAntenna(data.body.antenna.id, loginId);
}
@@ -207,7 +187,7 @@ globalThis.addEventListener('message', (ev: ServiceWorkerGlobalScopeEventMap['me
// Cache Storage全削除
await caches.keys()
.then(cacheNames => Promise.all(
cacheNames.map(name => caches.delete(name))
cacheNames.map(name => caches.delete(name)),
));
return; // TODO
}