mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 09:36:16 +01:00
closes #4335
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
"chat.user_typing": "%1 is typing ...",
|
||||
"chat.user_has_messaged_you": "%1 has messaged you.",
|
||||
"chat.see_all": "See all chats",
|
||||
"chat.mark_all_read": "Mark all chats read",
|
||||
"chat.no-messages": "Please select a recipient to view chat message history",
|
||||
"chat.no-users-in-room": "No users in this room",
|
||||
"chat.recent-chats": "Recent Chats",
|
||||
|
||||
@@ -7,8 +7,8 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
||||
var newMessage = false;
|
||||
|
||||
module.prepareDOM = function() {
|
||||
var chatsToggleEl = components.get('chat/dropdown'),
|
||||
chatsListEl = components.get('chat/list');
|
||||
var chatsToggleEl = components.get('chat/dropdown');
|
||||
var chatsListEl = components.get('chat/list');
|
||||
|
||||
chatsToggleEl.on('click', function() {
|
||||
if (chatsToggleEl.parent().hasClass('open')) {
|
||||
@@ -18,6 +18,14 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra
|
||||
module.loadChatsDropdown(chatsListEl);
|
||||
});
|
||||
|
||||
$('[component="chats/mark-all-read"]').on('click', function() {
|
||||
socket.emit('modules.chats.markAllRead', function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('event:chats.receive', function(data) {
|
||||
var username = data.message.fromUser.username;
|
||||
var isSelf = data.self === 1;
|
||||
|
||||
@@ -8,10 +8,16 @@ var sockets = require('../socket.io');
|
||||
module.exports = function(Messaging) {
|
||||
|
||||
Messaging.getUnreadCount = function(uid, callback) {
|
||||
if (!parseInt(uid, 10)) {
|
||||
return callback(null, 0);
|
||||
}
|
||||
db.sortedSetCard('uid:' + uid + ':chat:rooms:unread', callback);
|
||||
};
|
||||
|
||||
Messaging.pushUnreadCount = function(uid) {
|
||||
if (!parseInt(uid, 10)) {
|
||||
return callback(null, 0);
|
||||
}
|
||||
Messaging.getUnreadCount(uid, function(err, unreadCount) {
|
||||
if (err) {
|
||||
return;
|
||||
@@ -24,6 +30,10 @@ module.exports = function(Messaging) {
|
||||
db.sortedSetRemove('uid:' + uid + ':chat:rooms:unread', roomId, callback);
|
||||
};
|
||||
|
||||
Messaging.markAllRead = function(uid, callback) {
|
||||
db.delete('uid:' + uid + ':chat:rooms:unread', callback);
|
||||
};
|
||||
|
||||
Messaging.markUnread = function(uids, roomId, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
|
||||
@@ -61,7 +61,7 @@ SocketModules.chats.newRoom = function(socket, data, callback) {
|
||||
socket.lastChatMessageTime = now;
|
||||
}
|
||||
|
||||
Messaging.canMessageUser(socket.uid, data.touid, function(err, allowed) {
|
||||
Messaging.canMessageUser(socket.uid, data.touid, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -244,6 +244,18 @@ SocketModules.chats.markRead = function(socket, roomId, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
SocketModules.chats.markAllRead = function(socket, data, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Messaging.markAllRead(socket.uid, next);
|
||||
},
|
||||
function (next) {
|
||||
Messaging.pushUnreadCount(socket.uid);
|
||||
next();
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
SocketModules.chats.renameRoom = function(socket, data, callback) {
|
||||
if (!data) {
|
||||
return callback(new Error('[[error:invalid-name]]'));
|
||||
|
||||
Reference in New Issue
Block a user