mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 08:31:22 +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();
|
const { title, body, tag, data } = event.data.json();
|
||||||
|
|
||||||
if (title && body) {
|
if (title && body) {
|
||||||
|
const icon = data.icon;
|
||||||
|
delete data.icon;
|
||||||
|
const badge = data.badge;
|
||||||
|
delete data.badge;
|
||||||
|
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
self.registration.showNotification(title, { body, tag, data })
|
self.registration.showNotification(title, { body, tag, data, icon, badge })
|
||||||
);
|
);
|
||||||
} else if (tag) {
|
} else if (tag) {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ Notifications.findRelated = async function (mergeIds, set) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
// A related notification is one in a zset that has the same mergeId
|
// 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 keys = nids.map(nid => `notifications:${nid}`);
|
||||||
const notificationData = await db.getObjectsFields(keys, ['mergeId']);
|
const notificationData = await db.getObjectsFields(keys, ['mergeId']);
|
||||||
|
|||||||
Reference in New Issue
Block a user