Deleted
This commit is contained in:
@@ -57,6 +57,12 @@ const handlePushMessage = async (data) => {
|
||||
broadcastChannel.postMessage(message); // To potentially play sound
|
||||
|
||||
await addNotification({ subscriptionId, message });
|
||||
|
||||
// Don't show a notification for deleted messages
|
||||
if (message.deleted) {
|
||||
return;
|
||||
}
|
||||
|
||||
await self.registration.showNotification(
|
||||
...toNotificationParams({
|
||||
subscriptionId,
|
||||
|
||||
@@ -175,6 +175,7 @@ class SubscriptionManager {
|
||||
}
|
||||
|
||||
// Collapse notification updates based on sids, keeping only the latest version
|
||||
// Filters out notifications where the latest in the sequence is deleted
|
||||
groupNotificationsBySID(notifications) {
|
||||
const latestBySid = {};
|
||||
notifications.forEach((notification) => {
|
||||
@@ -184,7 +185,8 @@ class SubscriptionManager {
|
||||
latestBySid[key] = notification;
|
||||
}
|
||||
});
|
||||
return Object.values(latestBySid);
|
||||
// Filter out notifications where the latest is deleted
|
||||
return Object.values(latestBySid).filter((n) => !n.deleted);
|
||||
}
|
||||
|
||||
/** Adds notification, or returns false if it already exists */
|
||||
|
||||
@@ -18,6 +18,13 @@ const createDatabase = (username) => {
|
||||
prefs: "&key",
|
||||
});
|
||||
|
||||
db.version(5).stores({
|
||||
subscriptions: "&id,baseUrl,[baseUrl+mutedUntil]",
|
||||
notifications: "&id,sid,subscriptionId,time,new,deleted,[subscriptionId+new]", // added deleted index
|
||||
users: "&baseUrl,username",
|
||||
prefs: "&key",
|
||||
});
|
||||
|
||||
return db;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user