dont show invisible users in online users page

v1.18.x
Baris Soner Usakli 11 years ago
parent 700876fe58
commit 52962a7e9b

@ -52,8 +52,6 @@ define(function() {
return app.alert(err.message); return app.alert(err.message);
} }
console.log(data);
if (!data) { if (!data) {
$('#user-notfound-notify').html('You need to be logged in to search!'); $('#user-notfound-notify').html('You need to be logged in to search!');
$('#user-notfound-notify').parent().addClass('btn-warning label-warning'); $('#user-notfound-notify').parent().addClass('btn-warning label-warning');
@ -83,7 +81,7 @@ define(function() {
}); });
socket.on('user.isOnline', function(err, data) { socket.on('user.isOnline', function(err, data) {
if(getActiveSection() == 'online' && !loadingMoreUsers) { if(getActiveSection().indexOf('online') === 0 && !loadingMoreUsers) {
startLoading('users:online', 0, true); startLoading('users:online', 0, true);
socket.emit('user.getOnlineAnonCount', {} , function(err, anonCount) { socket.emit('user.getOnlineAnonCount', {} , function(err, anonCount) {
if(parseInt(anonCount, 10) > 0) { if(parseInt(anonCount, 10) > 0) {
@ -100,8 +98,11 @@ define(function() {
var html = templates.prepare(templates['users'].blocks['users']).parse({ var html = templates.prepare(templates['users'].blocks['users']).parse({
users: users users: users
}); });
if(emptyContainer)
if(emptyContainer) {
$('#users-container .registered-user').remove(); $('#users-container .registered-user').remove();
}
$('#users-container').append(html); $('#users-container').append(html);
$('#users-container .anon-user').appendTo($('#users-container')); $('#users-container .anon-user').appendTo($('#users-container'));
} }
@ -125,6 +126,7 @@ define(function() {
function startLoading(set, after, emptyContainer) { function startLoading(set, after, emptyContainer) {
loadingMoreUsers = true; loadingMoreUsers = true;
socket.emit('user.loadMore', { socket.emit('user.loadMore', {
set: set, set: set,
after: after after: after

@ -494,13 +494,19 @@ var fs = require('fs'),
var onlineUsers = []; var onlineUsers = [];
function iterator(user, callback) { data = data.filter(function(item) {
if(websockets.isUserOnline(user.uid)) { return item.status !== 'offline';
onlineUsers.push(user); });
} else {
db.sortedSetRemove('users:online', user.uid); function iterator(userData, next) {
var online = websockets.isUserOnline(userData.uid);
if(!online) {
db.sortedSetRemove('users:online', userData.uid);
return next(null);
} }
callback(null);
onlineUsers.push(userData);
next(null);
} }
var anonymousUserCount = websockets.getOnlineAnonCount(); var anonymousUserCount = websockets.getOnlineAnonCount();

@ -174,20 +174,28 @@ SocketUser.getActiveUsers = function(socket, data, callback) {
}; };
SocketUser.loadMore = function(socket, data, callback) { SocketUser.loadMore = function(socket, data, callback) {
if(data) { if(!data || !data.set || parseInt(data.after, 10) < 0) {
var start = data.after, return callback(new Error('invalid-data'));
end = start + 19; }
user.getUsers(data.set, start, end, function(err, data) { var start = data.after,
if(err) { end = start + 19;
return callback(err);
}
callback(null, { user.getUsers(data.set, start, end, function(err, userData) {
users: data if(err) {
return callback(err);
}
if(data.set === 'users:online') {
userData = userData.filter(function(item) {
return item.status !== 'offline';
}); });
}
callback(null, {
users: userData
}); });
} });
}; };
SocketUser.setStatus = function(socket, status, callback) { SocketUser.setStatus = function(socket, status, callback) {

Loading…
Cancel
Save