v1.18.x
barisusakli 11 years ago
parent 9c2bb027d3
commit 4e8a9fbe27

@ -9,7 +9,7 @@ define(function() {
var Browsing = {};
Browsing.onUpdateUsersInRoom = function(data) {
if(data && data.room.indexOf('topic') !== -1) {
if(data && data.room.indexOf('topic_' + ajaxify.variables.get('topic_id')) !== -1) {
var activeEl = $('.thread_active_users');
// remove users that are no longer here
@ -92,7 +92,7 @@ define(function() {
var user = activeEl.find('a[data-uid="'+ data.uid + '"]');
if (user.length && !data.online) {
user.parent().remove();
} else if(!user.length && data.online) {
} else if(!user.length && data.online && data.rooms.indexOf('topic_' + ajaxify.variables.get('topic_id')) !== -1) {
user = createUserIcon(data.uid, data.picture, data.userslug, data.username);
activeEl.append(user);
activeEl.find('a[data-uid] img').tooltip({
@ -107,7 +107,6 @@ define(function() {
}
}
function getReplyingUsers() {
var activeEl = $('.thread_active_users');
socket.emit('modules.composer.getUsersByTid', ajaxify.variables.get('topic_id'), function(err, uids) {

@ -228,6 +228,20 @@ Sockets.getUserSockets = function(uid) {
return sockets;
};
Sockets.getUserRooms = function(uid) {
var sockets = Sockets.getUserSockets(uid);
var rooms = {};
for (var i=0; i<sockets.length; ++i) {
var roomClients = io.sockets.manager.roomClients[sockets[i].id];
for (var roomName in roomClients) {
rooms[roomName.slice(1)] = true;
}
}
rooms = Object.keys(rooms);
return rooms;
};
/* Helpers */
Sockets.reqFromSocket = function(socket) {

@ -408,8 +408,8 @@ var bcrypt = require('bcryptjs'),
if(err) {
return callback(err);
}
var online = require('./socket.io').isUserOnline(uid);
var websockets = require('./socket.io');
var online = websockets.isUserOnline(uid);
data.status = online ? (data.status || 'online') : 'offline';
@ -420,7 +420,8 @@ var bcrypt = require('bcryptjs'),
data.online = online;
data.uid = uid;
data.timestamp = Date.now();
data.rooms = websockets.getUserRooms(uid);
console.log(data);
callback(null, data);
});
};

Loading…
Cancel
Save