From ae92378689e73895c3a250419a1ad874b25e40e3 Mon Sep 17 00:00:00 2001 From: tamaina Date: Wed, 13 Jul 2022 21:07:49 +0900 Subject: [PATCH] fix(sw, notification): Don't issue an event if there is no affect (#8979) * test * ]v] --- packages/backend/src/server/api/common/read-notification.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/common/read-notification.ts b/packages/backend/src/server/api/common/read-notification.ts index 17dd8e6f0..cf993ade3 100644 --- a/packages/backend/src/server/api/common/read-notification.ts +++ b/packages/backend/src/server/api/common/read-notification.ts @@ -12,13 +12,15 @@ export async function readNotification( if (notificationIds.length === 0) return; // Update documents - await Notifications.update({ + const result = await Notifications.update({ id: In(notificationIds), isRead: false, }, { isRead: true, }); + if (result.affected === 0) return; + if (!await Users.getHasUnreadNotification(userId)) return postReadAllNotifications(userId); else return postReadNotifications(userId, notificationIds); }