fix: messaging unread

dont mark chat room unread and then read right away for the user sending the message
This commit is contained in:
Barış Soner Uşaklı
2020-06-10 20:49:41 -04:00
parent 96cb94dcc6
commit 0041c02465
2 changed files with 10 additions and 12 deletions

View File

@@ -20,18 +20,20 @@ module.exports = function (Messaging) {
sockets.in('uid_' + uid).emit('event:unread.updateChatCount', unreadCount);
};
Messaging.markRead = async (uid, roomId) => db.sortedSetRemove('uid:' + uid + ':chat:rooms:unread', roomId);
Messaging.markAllRead = async uid => db.delete('uid:' + uid + ':chat:rooms:unread');
Messaging.markRead = async (uid, roomId) => {
await db.sortedSetRemove('uid:' + uid + ':chat:rooms:unread', roomId);
};
Messaging.markAllRead = async (uid) => {
await db.delete('uid:' + uid + ':chat:rooms:unread');
};
Messaging.markUnread = async (uids, roomId) => {
const exists = await Messaging.roomExists(roomId);
if (!exists) {
throw new Error('[[error:chat-room-does-not-exist]]');
}
var keys = uids.map(function (uid) {
return 'uid:' + uid + ':chat:rooms:unread';
});
const keys = uids.map(uid => 'uid:' + uid + ':chat:rooms:unread');
return await db.sortedSetsAdd(keys, Date.now(), roomId);
};
};