Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam
commit e8d6df22cb

@ -18,6 +18,13 @@ define(function() {
}; };
Admin.updateRoomUsage = function(err, data) { 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'), var active_users = $('#active_users'),
total = 0; total = 0;
@ -31,7 +38,7 @@ define(function() {
for (var room in data) { for (var room in data) {
if (room !== '') { if (room !== '') {
var count = $(data[room]).length; var count = getUserCountIn(room);
total += count; total += count;
usersHtml += "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div>"; usersHtml += "<div class='alert alert-success'><strong>" + room + "</strong> " + count + " active user" + (count > 1 ? "s" : "") + "</div>";
} }

@ -537,7 +537,8 @@ define(['composer'], function(composer) {
socket.on('get_users_in_room', function(data) { socket.on('get_users_in_room', function(data) {
if(data) {
if(data && data.room.indexOf('topic') !== -1) {
var activeEl = $('.thread_active_users'); var activeEl = $('.thread_active_users');
function createUserIcon(uid, picture, userslug, username) { function createUserIcon(uid, picture, userslug, username) {

@ -1,6 +1,6 @@
<div class="composer"> <div class="composer">
<div class="composer-container"> <div class="composer-container">
<input class="title" type="text" tabIndex="1" placeholder="Enter your topic title here..." /> <input class="title form-control" type="text" tabIndex="1" placeholder="Enter your topic title here..." />
<div class="btn-toolbar formatting-bar"> <div class="btn-toolbar formatting-bar">
<div class="btn-group"> <div class="btn-group">
<span class="btn btn-link" tabindex="-1"><i class="fa fa-bold"></i></span> <span class="btn btn-link" tabindex="-1"><i class="fa fa-bold"></i></span>
@ -24,7 +24,7 @@
<li><a data-pane=".tab-preview" data-toggle="tab">Preview</a></li> <li><a data-pane=".tab-preview" data-toggle="tab">Preview</a></li>
<li class="btn-group pull-right action-bar"> <li class="btn-group pull-right action-bar">
<button class="btn btn-default" data-action="discard" tabIndex="5"><i class="fa fa-times"></i> Discard</button> <button class="btn btn-default" data-action="discard" tabIndex="5"><i class="fa fa-times"></i> Discard</button>
<button data-action="post" class="btn btn-default" tabIndex="3"><i class="fa fa-check"></i> Submit</button> <button data-action="post" class="btn btn-default btn-primary" tabIndex="3"><i class="fa fa-check"></i> Submit</button>
</li> </li>
</ul> </ul>

@ -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(); emitOnlineUserCount();
@ -190,7 +198,6 @@ Sockets.emitUserCount = function() {
}); });
}; };
// Use sessionData.server.sockets.in() instead of this method.
Sockets.in = function(room) { Sockets.in = function(room) {
return io.sockets.in(room); return io.sockets.in(room);
}; };
@ -239,15 +246,15 @@ function updateRoomBrowsingText(roomName) {
var uids = getUidsInRoom(Sockets.rooms[roomName]), var uids = getUidsInRoom(Sockets.rooms[roomName]),
anonymousCount = getAnonymousCount(roomName); anonymousCount = getAnonymousCount(roomName);
if (uids.length === 0) { user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture'], function(err, users) {
io.sockets.in(roomName).emit('get_users_in_room', { users: [], anonymousCount: anonymousCount }); if(!err) {
} else { io.sockets.in(roomName).emit('get_users_in_room', {
user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture'], function(err, users) { users: users,
if(!err) { anonymousCount: anonymousCount,
io.sockets.in(roomName).emit('get_users_in_room', { users: users, anonymousCount: anonymousCount }); room: roomName
} });
}); }
} });
} }
Sockets.emitTopicPostStats = emitTopicPostStats; Sockets.emitTopicPostStats = emitTopicPostStats;

@ -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) { if (data.leave && server.rooms[data.leave] && server.rooms[data.leave][socket.id] && data.enter !== data.leave) {
delete server.rooms[data.leave][socket.id]; delete server.rooms[data.leave][socket.id];
if(!Object.keys(server.rooms[data.leave]).length) {
delete server.rooms[data.leave];
}
} }
} }

Loading…
Cancel
Save