Delete old messages with SID when new messages arrive

This commit is contained in:
binwiederhier
2026-01-08 10:28:02 -05:00
parent bfbe73aea3
commit 75abf2e245
4 changed files with 43 additions and 35 deletions

View File

@@ -57,6 +57,11 @@ export const useConnectionListeners = (account, subscriptions, users, webPushTop
};
const handleNewOrUpdatedNotification = async (subscriptionId, notification) => {
// Delete existing notification with same sid, if any
if (notification.sid) {
await subscriptionManager.deleteNotificationBySid(subscriptionId, notification.sid);
}
// Add notification to database
const added = await subscriptionManager.addNotification(subscriptionId, notification);
if (added) {
await subscriptionManager.notify(subscriptionId, notification);