use roomName if availabe in taskbar

if room is renamed update title on taskbar
This commit is contained in:
barisusakli
2017-01-23 13:02:35 +03:00
parent 73879b824c
commit 0b95eab71e
3 changed files with 24 additions and 9 deletions

View File

@@ -15,7 +15,14 @@ module.exports = function (Messaging) {
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
Messaging.notifyUsersInRoom = function (fromUid, roomId, messageObj) {
Messaging.getUidsInRoom(roomId, 0, -1, function (err, uids) {
async.parallel({
uids: function (next) {
Messaging.getUidsInRoom(roomId, 0, -1, next);
},
roomData: function (next) {
Messaging.getRoomData(roomId, next);
}
}, function (err, results) {
if (err) {
return;
}
@@ -23,9 +30,10 @@ module.exports = function (Messaging) {
var data = {
roomId: roomId,
fromUid: fromUid,
message: messageObj
message: messageObj,
roomName: results.roomData.roomName
};
uids.forEach(function (uid) {
results.uids.forEach(function (uid) {
data.self = parseInt(uid, 10) === parseInt(fromUid) ? 1 : 0;
Messaging.pushUnreadCount(uid);
sockets.in('uid_' + uid).emit('event:chats.receive', data);
@@ -43,7 +51,7 @@ module.exports = function (Messaging) {
}
queueObj.timeout = setTimeout(function () {
sendNotifications(fromUid, uids, roomId, queueObj.message, function (err) {
sendNotifications(fromUid, results.uids, roomId, queueObj.message, function (err) {
if (!err) {
delete Messaging.notifyQueue[fromUid + ':' + roomId];
}