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

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

@ -228,6 +228,20 @@ Sockets.getUserSockets = function(uid) {
return sockets; 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 */ /* Helpers */
Sockets.reqFromSocket = function(socket) { Sockets.reqFromSocket = function(socket) {

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

Loading…
Cancel
Save