Skip to content

Commit

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

* test

* ]v]
  • Loading branch information
tamaina committed Jul 13, 2022
1 parent 714c80b commit ae92378
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 ae92378

Please sign in to comment.