From 54c05f9027e0342b96976642b37d39de58073747 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sun, 19 Jan 2014 12:59:45 -0500 Subject: [PATCH 1/3] title is no longer centered in composer --- public/templates/composer.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/templates/composer.tpl b/public/templates/composer.tpl index f4649050bd..0c0ef31702 100644 --- a/public/templates/composer.tpl +++ b/public/templates/composer.tpl @@ -1,6 +1,6 @@
- +
@@ -24,7 +24,7 @@
  • Preview
  • - +
  • From 16a42619b56c5c031bc173b3809dd108a072eee0 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sun, 19 Jan 2014 14:27:07 -0500 Subject: [PATCH 2/3] closes #809 --- public/src/forum/topic.js | 3 ++- src/socket.io/index.js | 31 +++++++++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index e9d7f814cd..7bead051dd 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -537,7 +537,8 @@ define(['composer'], function(composer) { socket.on('get_users_in_room', function(data) { - if(data) { + + if(data && data.room.indexOf('topic') !== -1) { var activeEl = $('.thread_active_users'); function createUserIcon(uid, picture, userslug, username) { diff --git a/src/socket.io/index.js b/src/socket.io/index.js index c9657afd95..993b9bb8ed 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -94,7 +94,11 @@ Sockets.init = function() { }); } - io.sockets.in('global').emit('user.isOnline', isUserOnline(uid)); + socket.broadcast.emit('user.isOnline', null, { + online: isUserOnline(uid), + uid: uid, + timestamp: Date.now() + }); }); }); @@ -114,7 +118,11 @@ Sockets.init = function() { } } - io.sockets.in('global').emit('user.isOnline', isUserOnline(uid)); + socket.broadcast.emit('user.isOnline', null, { + online: isUserOnline(uid), + uid: uid, + timestamp: Date.now() + }); emitOnlineUserCount(); @@ -190,7 +198,6 @@ Sockets.emitUserCount = function() { }); }; -// Use sessionData.server.sockets.in() instead of this method. Sockets.in = function(room) { return io.sockets.in(room); }; @@ -239,15 +246,15 @@ function updateRoomBrowsingText(roomName) { var uids = getUidsInRoom(Sockets.rooms[roomName]), anonymousCount = getAnonymousCount(roomName); - if (uids.length === 0) { - io.sockets.in(roomName).emit('get_users_in_room', { users: [], anonymousCount: anonymousCount }); - } else { - user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture'], function(err, users) { - if(!err) { - io.sockets.in(roomName).emit('get_users_in_room', { users: users, anonymousCount: anonymousCount }); - } - }); - } + user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture'], function(err, users) { + if(!err) { + io.sockets.in(roomName).emit('get_users_in_room', { + users: users, + anonymousCount: anonymousCount, + room: roomName + }); + } + }); } Sockets.emitTopicPostStats = emitTopicPostStats; From 1980e945dae75125be68ec32061658b7e7e9f155 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sun, 19 Jan 2014 14:42:47 -0500 Subject: [PATCH 3/3] fixed admin page active sockets --- public/src/forum/admin/index.js | 9 ++++++++- src/socket.io/meta.js | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public/src/forum/admin/index.js b/public/src/forum/admin/index.js index ba45405cf6..c0806106dd 100644 --- a/public/src/forum/admin/index.js +++ b/public/src/forum/admin/index.js @@ -18,6 +18,13 @@ define(function() { }; Admin.updateRoomUsage = function(err, data) { + function getUserCountIn(room) { + var count = 0; + for(var user in data[room]) { + ++count; + } + return count; + } var active_users = $('#active_users'), total = 0; @@ -31,7 +38,7 @@ define(function() { for (var room in data) { if (room !== '') { - var count = $(data[room]).length; + var count = getUserCountIn(room); total += count; usersHtml += "
    " + room + " " + count + " active user" + (count > 1 ? "s" : "") + "
    "; } diff --git a/src/socket.io/meta.js b/src/socket.io/meta.js index 9c8d2b8ed8..106c6d5621 100644 --- a/src/socket.io/meta.js +++ b/src/socket.io/meta.js @@ -91,6 +91,9 @@ SocketMeta.rooms.enter = function(socket, data) { if (data.leave && server.rooms[data.leave] && server.rooms[data.leave][socket.id] && data.enter !== data.leave) { delete server.rooms[data.leave][socket.id]; + if(!Object.keys(server.rooms[data.leave]).length) { + delete server.rooms[data.leave]; + } } }