This commit is contained in:
tamaina 2023-02-18 14:11:45 +00:00
parent 8c883653c9
commit cd5615d354

View file

@ -14,7 +14,7 @@ const closeNotificationsByTags = async (tags: string[]) => {
for (const n of (await Promise.all(tags.map(tag => globalThis.registration.getNotifications({ tag })))).flat()) { for (const n of (await Promise.all(tags.map(tag => globalThis.registration.getNotifications({ tag })))).flat()) {
n.close(); n.close();
} }
} };
const iconUrl = (name: badgeNames) => `/static-assets/tabler-badges/${name}.png`; const iconUrl = (name: badgeNames) => `/static-assets/tabler-badges/${name}.png`;
/* How to add a new badge: /* How to add a new badge:
@ -183,11 +183,10 @@ async function composeNotification(data: pushNotificationDataMap[keyof pushNotif
} }
case 'pollEnded': case 'pollEnded':
const tag = `poll:${data.body.note.id}`;
return [t('_notification.pollEnded'), { return [t('_notification.pollEnded'), {
body: data.body.note.text || '', body: data.body.note.text || '',
badge: iconUrl('chart-arrows'), badge: iconUrl('chart-arrows'),
tag, tag: `poll:${data.body.note.id}`,
data, data,
}]; }];
@ -228,12 +227,11 @@ async function composeNotification(data: pushNotificationDataMap[keyof pushNotif
return null; return null;
} }
case 'unreadAntennaNote': case 'unreadAntennaNote':
const tag = `antenna:${data.body.antenna.id}`;
return [t('_notification.unreadAntennaNote', { name: data.body.antenna.name }), { return [t('_notification.unreadAntennaNote', { name: data.body.antenna.name }), {
body: `${getUserName(data.body.note.user)}: ${data.body.note.text ?? ''}`, body: `${getUserName(data.body.note.user)}: ${data.body.note.text ?? ''}`,
icon: data.body.note.user.avatarUrl, icon: data.body.note.user.avatarUrl,
badge: iconUrl('antenna'), badge: iconUrl('antenna'),
tag, tag: `antenna:${data.body.antenna.id}`,
data, data,
renotify: true, renotify: true,
}]; }];