From a317a4d6895f645d13aeadc1e55623d8bcd682bc Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Tue, 27 Aug 2013 13:32:43 -0400 Subject: [PATCH] closes #206 --- src/categories.js | 74 ++++++++++++++++++++++++++++++++++++++++++++++ src/plugins.js | 2 +- src/posts.js | 2 +- src/threadTools.js | 7 +++++ src/topics.js | 22 ++++++++++++++ 5 files changed, 105 insertions(+), 2 deletions(-) diff --git a/src/categories.js b/src/categories.js index 01c831c5af..479bd29d41 100644 --- a/src/categories.js +++ b/src/categories.js @@ -74,6 +74,7 @@ var RDB = require('./redis.js'), categoryData.moderator_block_class = results[1].length > 0 ? '' : 'none'; categoryData.moderators = results[1]; categoryData.active_users = results[2]; + categoryData.show_sidebar = categoryData.topics.length > 0 ? 'show':'hidden'; callback(null, categoryData); }); } @@ -234,6 +235,26 @@ var RDB = require('./redis.js'), }); } + Categories.moveActiveUsers = function(tid, oldCid, cid, callback) { + topics.getUids(tid, function(err, uids) { + if(!err && uids) { + function updateUser(uid) { + Categories.addActiveUser(cid, uid); + Categories.isUserActiveIn(oldCid, uid, function(err, active) { + + if(!err && !active) { + Categories.removeActiveUser(oldCid, uid); + } + }); + } + + for(var i=0; i