active users fix

v1.18.x
Baris Soner Usakli 11 years ago
parent fb691b23b4
commit 1b7f8cc5cb

@ -618,6 +618,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
]);
socket.on('get_users_in_room', function(data) {
if(data && data.room.indexOf('topic') !== -1) {
var activeEl = $('li.post-bar[data-index="0"] .thread_active_users');
@ -636,9 +637,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
// remove users that are no longer here
activeEl.find('a').each(function(index, element) {
if(element) {
var uid = $(element).attr('data-uid'),
absent = data.users.every(function(aUid) {
return parseInt(aUid, 10) !== parseInt(uid, 10);
var uid = $(element).attr('data-uid');
absent = data.users.every(function(user) {
return parseInt(user.uid, 10) !== parseInt(uid, 10);
});
if (absent) {

@ -131,6 +131,7 @@ Sockets.init = function(server) {
emitOnlineUserCount();
for(var roomName in io.sockets.manager.roomClients[socket.id]) {
console.log('disconnected from', roomName);
updateRoomBrowsingText(roomName.slice(1));
}
});
@ -235,7 +236,11 @@ function isUserOnline(uid) {
Sockets.updateRoomBrowsingText = updateRoomBrowsingText;
function updateRoomBrowsingText(roomName) {
function getUidsInRoom(room) {
if (!roomName) {
return;
}
function getUidsInRoom() {
var uids = [];
var clients = io.sockets.clients(roomName);
for(var i=0; i<clients.length; ++i) {
@ -246,7 +251,7 @@ function updateRoomBrowsingText(roomName) {
return uids;
}
function getAnonymousCount(roomName) {
function getAnonymousCount() {
var clients = io.sockets.clients(roomName);
var anonCount = 0;
@ -258,15 +263,17 @@ function updateRoomBrowsingText(roomName) {
return anonCount;
}
var uids = getUidsInRoom(roomName),
anonymousCount = getAnonymousCount(roomName);
var uids = getUidsInRoom(),
anonymousCount = getAnonymousCount();
user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture', 'status'], function(err, users) {
if(!err) {
users = users.filter(function(user) {
return user.status !== 'offline';
});
console.log('['+roomName+']', users.length, anonymousCount);
io.sockets.in(roomName).emit('get_users_in_room', {
users: users,
anonymousCount: anonymousCount,

@ -85,7 +85,7 @@ SocketMeta.rooms.enter = function(socket, data) {
socket.join(data.enter);
if (data.leave) {
if (data.leave && data.leave !== data.enter) {
module.parent.exports.updateRoomBrowsingText(data.leave);
}

@ -135,13 +135,8 @@ SocketModules.composer.pingActive = function(socket, uuid) {
SocketModules.composer.getUsersByTid = function(socket, tid, callback) {
// Return uids with active composers
console.log(tid);
callback(null, _.filter(SocketModules.composer.replyHash, function(replyObj, uuid) {
if (parseInt(replyObj.tid, 10) === parseInt(tid, 10)) {
return true;
} else {
return false;
}
return parseInt(replyObj.tid, 10) === parseInt(tid, 10);
}).map(function(replyObj) {
return replyObj.uid
}));

Loading…
Cancel
Save