mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: notifications.markAllRead
so that it actually marks all notifications read instead of the most recent 100. if you had more than 100 unread it required clicking multiple times. also don't use markReadMultiple since we are clearing them all.
This commit is contained in:
@@ -383,8 +383,17 @@ Notifications.markReadMultiple = async function (nids, uid) {
|
||||
};
|
||||
|
||||
Notifications.markAllRead = async function (uid) {
|
||||
const nids = await db.getSortedSetRevRange(`uid:${uid}:notifications:unread`, 0, 99);
|
||||
await Notifications.markReadMultiple(nids, uid);
|
||||
await batch.processSortedSet(`uid:${uid}:notifications:unread`, async (unreadNotifs) => {
|
||||
const nids = unreadNotifs.map(n => n && n.value);
|
||||
const datetimes = unreadNotifs.map(n => n && n.score);
|
||||
await Promise.all([
|
||||
db.sortedSetRemove(`uid:${uid}:notifications:unread`, nids),
|
||||
db.sortedSetAdd(`uid:${uid}:notifications:read`, datetimes, nids),
|
||||
]);
|
||||
}, {
|
||||
withScores: true,
|
||||
batch: 500,
|
||||
});
|
||||
};
|
||||
|
||||
Notifications.prune = async function () {
|
||||
|
||||
Reference in New Issue
Block a user