Skip to content

Node.js based forum software built for the modern web

feat: service worker icon and badge support

Julian Lam4ae861457339
diff --git a/public/src/service-worker.js b/public/src/service-worker.js
index 63cb1704e5..3f1c5e0bc5 100644
--- a/public/src/service-worker.js
+++ b/public/src/service-worker.js
@@ -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(
diff --git a/src/notifications.js b/src/notifications.js
index ce4245fba7..1d020e536b 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -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']);