From 6ab5f42ef0d44eabf95af8ba9a8258bdbca88104 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sun, 9 Feb 2014 18:45:41 -0500 Subject: [PATCH] only update anon count if on online page --- public/src/forum/users.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/public/src/forum/users.js b/public/src/forum/users.js index 3021ad36dc..5e780b4670 100644 --- a/public/src/forum/users.js +++ b/public/src/forum/users.js @@ -92,15 +92,18 @@ define(function() { socket.on('user.anonConnect', updateAnonCount) function updateAnonCount() { - socket.emit('user.getOnlineAnonCount', {} , function(err, anonCount) { - - if(parseInt(anonCount, 10) > 0) { - $('#users-container .anon-user').removeClass('hide'); - $('#online_anon_count').html(anonCount); - } else { - $('#users-container .anon-user').addClass('hide'); - } - }); + var section = getActiveSection(); + if((section.indexOf('online') === 0 || section.indexOf('users') === 0) && !loadingMoreUsers) { + socket.emit('user.getOnlineAnonCount', {} , function(err, anonCount) { + + if(parseInt(anonCount, 10) > 0) { + $('#users-container .anon-user').removeClass('hide'); + $('#online_anon_count').html(anonCount); + } else { + $('#users-container .anon-user').addClass('hide'); + } + }); + } } function onUsersLoaded(users, emptyContainer) {