Skip to content

Commit

Permalink
fix(sw, notification): Don't issue an event if there is no affect (mi…
Browse files Browse the repository at this point in the history
…sskey-dev#8979)

* test

* ]v]
  • Loading branch information
tamaina authored and Johann150 committed Jul 14, 2022
1 parent 0c5f857 commit 95ea248
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/backend/src/server/api/common/read-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 95ea248

Please sign in to comment.