tried fixing absentee detection in active users

v1.18.x
Julian Lam 11 years ago
parent 079ed10631
commit 1c324f45cf

@ -622,17 +622,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
var activeEl = $('li.post-bar[data-index="0"] .thread_active_users'); var activeEl = $('li.post-bar[data-index="0"] .thread_active_users');
function createUserIcon(uid, picture, userslug, username) { function createUserIcon(uid, picture, userslug, username) {
if(!activeEl.find('[data-uid="' + uid + '"]').length) {
if(!activeEl.find('[href="'+ RELATIVE_PATH +'/user/' + data.users[i].userslug + '"]').length) { var div = $('<div class="inline-block"><a data-uid="' + uid + '" href="' + RELATIVE_PATH + '/user/' + userslug + '"><img src="'+ picture +'"/></a></div>');
var userIcon = $('<img src="'+ picture +'"/>'); div.find('a').tooltip({
var userLink = $('<a href="' + RELATIVE_PATH + '/user/' + userslug + '"></a>').append(userIcon);
userLink.attr('data-uid', uid);
var div = $('<div class="inline-block"></div>');
div.append(userLink);
userLink.tooltip({
placement: 'top', placement: 'top',
title: username title: username
}); });
@ -642,15 +634,16 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
} }
// remove users that are no longer here // remove users that are no longer here
activeEl.children().each(function(index, element) { activeEl.find('a').each(function(index, element) {
if(element) { if(element) {
var uid = $(element).attr('data-uid'); var uid = $(element).attr('data-uid'),
for(var i=0; i<data.users.length; ++i) { absent = data.users.every(function(aUid) {
if(data.users[i].uid == uid) { return parseInt(aUid, 10) !== parseInt(uid, 10);
return; });
}
if (absent) {
$(element).remove();
} }
$(element).remove();
} }
}); });

Loading…
Cancel
Save