fix(sw, notification): Don't issue an event if there is no affect (#8979)

* test

* ]v]
This commit is contained in:
tamaina 2022-07-13 21:07:49 +09:00 committed by Johann150
parent 0c5f8579d5
commit 95ea2485c1
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -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);
}