From c294c3b342a03af5dbde28ec04258265f9c558c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 1 Apr 2015 16:41:14 -0400 Subject: [PATCH] fix inf scroll and timeago on users page --- public/src/client/users.js | 10 ++++++---- src/socket.io/user.js | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/public/src/client/users.js b/public/src/client/users.js index 11f1deb7bb..0a08454ecb 100644 --- a/public/src/client/users.js +++ b/public/src/client/users.js @@ -62,7 +62,7 @@ define('forum/users', ['translator'], function(translator) { after: after }, function(err, data) { if (data && data.users.length) { - onUsersLoaded(data.users); + onUsersLoaded(data); $('#load-more-users-btn').removeClass('disabled'); } else { $('#load-more-users-btn').addClass('disabled'); @@ -71,13 +71,15 @@ define('forum/users', ['translator'], function(translator) { }); } - function onUsersLoaded(users) { - users = users.filter(function(user) { + function onUsersLoaded(data) { + data.users = data.users.filter(function(user) { return !$('.users-box[data-uid="' + user.uid + '"]').length; }); - templates.parse('users', 'users', {users: users}, function(html) { + templates.parse('users', 'users', data, function(html) { translator.translate(html, function(translated) { + translated = $(translated); + translated.find('span.timeago').timeago(); $('#users-container').append(translated); $('#users-container .anon-user').appendTo($('#users-container')); }); diff --git a/src/socket.io/user.js b/src/socket.io/user.js index 5b4db66495..850edff7d0 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -426,11 +426,12 @@ SocketUser.loadMore = function(socket, data, callback) { return user.status !== 'offline'; }); } - - callback(null, { + var result = { users: results.users, - nextStart: stop + 1 - }); + nextStart: stop + 1, + }; + result['route_' + data.set] = true; + callback(null, result); }); };