Node.js based forum software built for the modern web
do a single filter after getting all unread tids
barisusaklib5cc852551e3
diff --git a/src/topics/unread.js b/src/topics/unread.jsindex 8bdc8a04e2..2754fa9a88 100644--- a/src/topics/unread.js+++ b/src/topics/unread.js@@ -23,48 +23,45 @@ module.exports = function(Topics) {done = false;uid = parseInt(uid, 10);- if(uid === 0) {+ if (uid === 0) {return callback(null, unreadTids);}async.whilst(function() {return unreadTids.length < 21 && !done;- }, function(callback) {+ }, function(next) {Topics.getLatestTids(start, stop, 'month', function(err, tids) {if (err) {- return callback(err);+ return next(err);}if (tids && !tids.length) {done = true;- return callback();+ return next();}Topics.hasReadTopics(tids, uid, function(err, read) {- if(err) {- return callback(err);+ if (err) {+ return next(err);}var newtids = tids.filter(function(tid, index) {return !read[index];});- privileges.topics.filter('read', newtids, uid, function(err, newtids) {- if(err) {- return callback(err);- }-- unreadTids.push.apply(unreadTids, newtids);+ unreadTids.push.apply(unreadTids, newtids);- start = stop + 1;- stop = start + 19;+ start = stop + 1;+ stop = start + 19;- callback();- });+ next();});});}, function(err) {- callback(err, unreadTids);+ if (err) {+ return callback(err);+ }+ privileges.topics.filter('read', unreadTids, uid, callback);});};