mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
correctly hide/show user in browsing users
This commit is contained in:
@@ -185,7 +185,8 @@ app.cacheBuster = null;
|
|||||||
enter: room,
|
enter: room,
|
||||||
username: app.user.username,
|
username: app.user.username,
|
||||||
userslug: app.user.userslug,
|
userslug: app.user.userslug,
|
||||||
picture: app.user.picture
|
picture: app.user.picture,
|
||||||
|
status: app.user.status
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
app.alertError(err.message);
|
||||||
@@ -454,6 +455,7 @@ app.cacheBuster = null;
|
|||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
$('#logged-in-menu #user_label #user-profile-link>i').attr('class', 'fa fa-circle status ' + status);
|
$('#logged-in-menu #user_label #user-profile-link>i').attr('class', 'fa fa-circle status ' + status);
|
||||||
|
app.user.status = status;
|
||||||
});
|
});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
/* globals define, app, config, socket, ajaxify */
|
/* globals define, app, config, socket, ajaxify */
|
||||||
|
|
||||||
define('forum/topic/browsing', ['translator'], function(translator) {
|
define('forum/topic/browsing', function() {
|
||||||
|
|
||||||
var Browsing = {};
|
var Browsing = {};
|
||||||
|
|
||||||
Browsing.onUpdateUsersInRoom = function(data) {
|
Browsing.onUpdateUsersInRoom = function(data) {
|
||||||
if (data && data.room.indexOf('topic_' + ajaxify.data.tid) !== -1) {
|
if (data && data.room.indexOf('topic_' + ajaxify.data.tid) !== -1) {
|
||||||
$('[component="topic/browsing/list"]').parent().toggleClass('hidden', !data.users.length);
|
$('[component="topic/browsing/list"]').parent().toggleClass('hidden', !data.users.length);
|
||||||
for(var i=0; i<data.users.length; ++i) {
|
for (var i=0; i<data.users.length; ++i) {
|
||||||
addUserIcon(data.users[i]);
|
addUserIcon(data.users[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ define('forum/topic/browsing', ['translator'], function(translator) {
|
|||||||
} else {
|
} else {
|
||||||
increaseUserCount(1);
|
increaseUserCount(1);
|
||||||
}
|
}
|
||||||
|
Browsing.onUserStatusChange(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
Browsing.onUserLeave = function(uid) {
|
Browsing.onUserLeave = function(uid) {
|
||||||
@@ -56,8 +57,8 @@ define('forum/topic/browsing', ['translator'], function(translator) {
|
|||||||
function updateBrowsingUsers(data) {
|
function updateBrowsingUsers(data) {
|
||||||
var activeEl = $('[component="topic/browsing/list"]');
|
var activeEl = $('[component="topic/browsing/list"]');
|
||||||
var user = activeEl.find('a[data-uid="'+ data.uid + '"]');
|
var user = activeEl.find('a[data-uid="'+ data.uid + '"]');
|
||||||
if (user.length && data.status === 'offline') {
|
if (user.length) {
|
||||||
user.parent().remove();
|
user.parent().toggleClass('hidden', data.status === 'offline');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ define('forum/topic/browsing', ['translator'], function(translator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createUserIcon(uid, picture, userslug, username) {
|
function createUserIcon(uid, picture, userslug, username) {
|
||||||
if(!$('[component="topic/browsing/list"]').find('[data-uid="' + uid + '"]').length) {
|
if (!$('[component="topic/browsing/list"]').find('[data-uid="' + uid + '"]').length) {
|
||||||
return $('<div class="inline-block"><a title="' + username + '" data-uid="' + uid + '" data-count="1" href="' + config.relative_path + '/user/' + userslug + '"><img src="'+ picture +'"/></a></div>');
|
return $('<div class="inline-block"><a title="' + username + '" data-uid="' + uid + '" data-count="1" href="' + config.relative_path + '/user/' + userslug + '"><img src="'+ picture +'"/></a></div>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user