mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 07:10:30 +01:00
feat: service worker icon and badge support
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user