feat: service worker icon and badge support

This commit is contained in:
Julian Lam
2024-09-20 11:19:50 -04:00
parent 6b4b4b1a00
commit 4ae8614573
2 changed files with 7 additions and 2 deletions

View File

@@ -43,8 +43,13 @@ self.addEventListener('push', function (event) {
const { title, body, tag, data } = event.data.json();
if (title && body) {
const icon = data.icon;
delete data.icon;
const badge = data.badge;
delete data.badge;
event.waitUntil(
self.registration.showNotification(title, { body, tag, data })
self.registration.showNotification(title, { body, tag, data, icon, badge })
);
} else if (tag) {
event.waitUntil(

View File

@@ -127,7 +127,7 @@ Notifications.findRelated = async function (mergeIds, set) {
return [];
}
// A related notification is one in a zset that has the same mergeId
const nids = await db.getSortedSetRevRange(set, 0, -1);
const nids = await db.getSortedSetMembers(set);
const keys = nids.map(nid => `notifications:${nid}`);
const notificationData = await db.getObjectsFields(keys, ['mergeId']);