summaryrefslogtreecommitdiff
path: root/packages/sw/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-02-15 13:06:06 +0900
committerGitHub <noreply@github.com>2023-02-15 13:06:06 +0900
commit8f2049bcd261c3fb10afdc8c15cf4edffe1baa71 (patch)
treedc5aa1cefc24d3f6eb36bb1723d7433f8a19e5a2 /packages/sw/src
parentMerge branch 'develop' of https://github.com/misskey-dev/misskey into develop (diff)
downloadsharkey-8f2049bcd261c3fb10afdc8c15cf4edffe1baa71.tar.gz
sharkey-8f2049bcd261c3fb10afdc8c15cf4edffe1baa71.tar.bz2
sharkey-8f2049bcd261c3fb10afdc8c15cf4edffe1baa71.zip
drop messaging (#9919)
* drop messaging (from backend) * wip
Diffstat (limited to 'packages/sw/src')
-rw-r--r--packages/sw/src/scripts/create-notification.ts17
-rw-r--r--packages/sw/src/sw.ts34
-rw-r--r--packages/sw/src/types.ts3
3 files changed, 7 insertions, 47 deletions
diff --git a/packages/sw/src/scripts/create-notification.ts b/packages/sw/src/scripts/create-notification.ts
index 6e7845f667..1ec4491273 100644
--- a/packages/sw/src/scripts/create-notification.ts
+++ b/packages/sw/src/scripts/create-notification.ts
@@ -236,23 +236,6 @@ async function composeNotification(data: pushNotificationDataMap[keyof pushNotif
default:
return null;
}
- case 'unreadMessagingMessage':
- if (data.body.groupId === null) {
- return [t('_notification.youGotMessagingMessageFromUser', { name: getUserName(data.body.user) }), {
- icon: data.body.user.avatarUrl,
- badge: iconUrl('messages'),
- tag: `messaging:user:${data.body.userId}`,
- data,
- renotify: true,
- }];
- }
- return [t('_notification.youGotMessagingMessageFromGroup', { name: data.body.group?.name ?? '' }), {
- icon: data.body.user.avatarUrl,
- badge: iconUrl('messages'),
- tag: `messaging:group:${data.body.groupId}`,
- data,
- renotify: true,
- }];
case 'unreadAntennaNote':
return [t('_notification.unreadAntennaNote', { name: data.body.antenna.name }), {
body: `${getUserName(data.body.note.user)}: ${data.body.note.text ?? ''}`,
diff --git a/packages/sw/src/sw.ts b/packages/sw/src/sw.ts
index 7bcf4d5976..f56208d6d6 100644
--- a/packages/sw/src/sw.ts
+++ b/packages/sw/src/sw.ts
@@ -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
}
diff --git a/packages/sw/src/types.ts b/packages/sw/src/types.ts
index 3b35de4079..5b53ddecac 100644
--- a/packages/sw/src/types.ts
+++ b/packages/sw/src/types.ts
@@ -13,15 +13,12 @@ export type SwMessage = {
// Defined also @/core/PushNotificationService.ts#L12
type pushNotificationDataSourceMap = {
notification: Misskey.entities.Notification;
- unreadMessagingMessage: Misskey.entities.MessagingMessage;
unreadAntennaNote: {
antenna: { id: string, name: string };
note: Misskey.entities.Note;
};
readNotifications: { notificationIds: string[] };
readAllNotifications: undefined;
- readAllMessagingMessages: undefined;
- readAllMessagingMessagesOfARoom: { userId: string } | { groupId: string };
readAntenna: { antennaId: string };
readAllAntennas: undefined;
};