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

v1.18.x
Julian Lam 11 years ago
commit 2e407b1f78

@ -458,6 +458,13 @@ var socket,
}); });
}; };
function updateOnlineStatus(uid) {
socket.emit('user.isOnline', uid, function(err, data) {
$('#logged-in-menu #user_label #user-profile-link>i').attr('class', 'fa fa-circle status-' + data.status);
});
}
app.updateHeader = function(err, data) { app.updateHeader = function(err, data) {
$('#search-button').off().on('click', function(e) { $('#search-button').off().on('click', function(e) {
e.stopPropagation(); e.stopPropagation();
@ -500,11 +507,14 @@ var socket,
userLabel.find('img').attr('src', data.picture); userLabel.find('img').attr('src', data.picture);
} }
if (data.username) { if (data.username) {
userLabel.find('#user-profile-link>span').html(data.username); userLabel.find('#user-profile-link>span').html(' ' + data.username);
} }
$('#logout-link').on('click', app.logout); $('#logout-link').on('click', app.logout);
} }
updateOnlineStatus(data.uid);
} else { } else {
if (allowGuestSearching) { if (allowGuestSearching) {
$('#search-button').removeClass("hide").show(); $('#search-button').removeClass("hide").show();
@ -528,12 +538,14 @@ var socket,
} }
}); });
$('#user-control-list .user-status').off('click').on('click', function() { $('#user-control-list .user-status').off('click').on('click', function(e) {
socket.emit('user.setStatus', $(this).attr('data-status'), function(err) { socket.emit('user.setStatus', $(this).attr('data-status'), function(err, data) {
if(err) { if(err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
updateOnlineStatus(data.uid);
}); });
e.preventDefault();
}); });
}; };

@ -203,6 +203,7 @@ SocketUser.setStatus = function(socket, status, callback) {
user.setUserField(socket.uid, 'status', status, function(err) { user.setUserField(socket.uid, 'status', status, function(err) {
SocketUser.isOnline(socket, socket.uid, function(err, data) { SocketUser.isOnline(socket, socket.uid, function(err, data) {
server.server.sockets.emit('user.isOnline', err, data); server.server.sockets.emit('user.isOnline', err, data);
callback(err, data);
}); });
}); });
}; };

Loading…
Cancel
Save