From 7cffbfcd6d78c02df0e9b1da2353451f359ed8f1 Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Thu, 8 Jan 2026 13:43:57 -0500 Subject: [PATCH] Simplify handleNotifications --- web/src/components/hooks.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/web/src/components/hooks.js b/web/src/components/hooks.js index 588697fc..9f836156 100644 --- a/web/src/components/hooks.js +++ b/web/src/components/hooks.js @@ -50,26 +50,18 @@ export const useConnectionListeners = (account, subscriptions, users, webPushTop }; const handleNotification = async (subscriptionId, notification) => { - if (notification.deleted && notification.sid) { - return handleDeletedNotification(subscriptionId, notification); - } - return handleNewOrUpdatedNotification(subscriptionId, notification); - }; - - 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); - } - }; - const handleDeletedNotification = async (subscriptionId, notification) => { - await subscriptionManager.deleteNotificationBySid(subscriptionId, notification.sid); + // Add notification to database + if (!notification.deleted) { + const added = await subscriptionManager.addNotification(subscriptionId, notification); + if (added) { + await subscriptionManager.notify(subscriptionId, notification); + } + } }; const handleMessage = async (subscriptionId, message) => {