From f8ae7b069c42149032b4466a4d7284214f8b7f7b Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 3 Nov 2016 14:47:44 +0300 Subject: [PATCH] cid filter --- src/controllers/recent.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/recent.js b/src/controllers/recent.js index 607bd5d9f4..93ca83c6bc 100644 --- a/src/controllers/recent.js +++ b/src/controllers/recent.js @@ -38,7 +38,7 @@ recentController.get = function (req, res, next) { user.getSettings(req.uid, next); }, tids: function (next) { - db.getSortedSetRevRange('topics:recent', 0, 199, next); + db.getSortedSetRevRange(cid ? 'cid:' + cid + ':tids' : 'topics:recent', 0, 199, next); }, watchedCategories: function (next) { helpers.getWatchedCategories(req.uid, cid, next); @@ -48,7 +48,7 @@ recentController.get = function (req, res, next) { function (results, next) { settings = results.settings; categoryData = results.watchedCategories; - filterTids(results.tids, req.uid, cid, categoryData.categories, filter, next); + filterTids(results.tids, req.uid, categoryData.categories, filter, next); }, function (tids, next) { var start = Math.max(0, (page - 1) * settings.topicsPerPage); @@ -104,7 +104,7 @@ recentController.get = function (req, res, next) { }); }; -function filterTids(tids, uid, cid, watchedCategories, filter, callback) { +function filterTids(tids, uid, watchedCategories, filter, callback) { async.waterfall([ function (next) { if (filter === 'watched') { @@ -129,7 +129,7 @@ function filterTids(tids, uid, cid, watchedCategories, filter, callback) { tids = topicData.filter(function (topic, index) { if (topic) { var topicCid = parseInt(topic.cid, 10); - return watchedCids.indexOf(topicCid) !== -1 && (!cid || parseInt(cid, 10) === topicCid); + return watchedCids.indexOf(topicCid) !== -1; } else { return false; }