From 1b7f8cc5cb4da8b506bebeb342b7d61c5afb973a Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sat, 1 Mar 2014 22:51:39 -0500 Subject: [PATCH] active users fix --- public/src/forum/topic.js | 7 ++++--- src/socket.io/index.js | 17 ++++++++++++----- src/socket.io/meta.js | 2 +- src/socket.io/modules.js | 7 +------ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index d25d76283e..6a697f5849 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -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) { diff --git a/src/socket.io/index.js b/src/socket.io/index.js index 551edac088..bc7748b9ce 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -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