From 08dfb3470c6fd77a9b51f6360a9fb1cc18bd565a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 14 Sep 2018 18:00:52 -0400 Subject: [PATCH] fix tests --- src/topics/unread.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/topics/unread.js b/src/topics/unread.js index 500b429cd2..cb197fac21 100644 --- a/src/topics/unread.js +++ b/src/topics/unread.js @@ -207,11 +207,18 @@ module.exports = function (Topics) { } function doesTidHaveUnblockedUnreadPosts(uid, tid, callback) { + var topicTimestamp; + var userLastReadTimestamp; async.waterfall([ function (next) { - db.sortedSetScore('uid:' + uid + ':tids_read', tid, next); + async.parallel({ + topicTimestamp: async.apply(db.sortedSetScore, 'topics:recent', tid), + userLastReadTimestamp: async.apply(db.sortedSetScore, 'uid:' + uid + ':tids_read', tid), + }, next); }, - function (userLastReadTimestamp, next) { + function (results, next) { + topicTimestamp = results.topicTimestamp; + userLastReadTimestamp = results.userLastReadTimestamp; if (!userLastReadTimestamp) { return callback(null, true); } @@ -219,7 +226,7 @@ module.exports = function (Topics) { }, function (pidsSinceLastVisit, next) { if (!pidsSinceLastVisit.length) { - return callback(null, false); + return callback(null, topicTimestamp > userLastReadTimestamp); } posts.getPostsFields(pidsSinceLastVisit, ['pid', 'uid'], next); },