From c33b369858a54841c6f1388c5e4265935e6c19d0 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 27 Jan 2015 10:36:30 -0500 Subject: [PATCH] closes #2658 --- src/topics/unread.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/topics/unread.js b/src/topics/unread.js index 4683395f6f..a12f1c4d77 100644 --- a/src/topics/unread.js +++ b/src/topics/unread.js @@ -154,11 +154,9 @@ module.exports = function(Topics) { return callback(); } tids = tids.filter(Boolean); - - var now = Date.now(); - var scores = tids.map(function(tid) { - return now; - }); + if (!tids.length) { + return callback(); + } async.parallel({ topicScores: function(next) { @@ -180,6 +178,11 @@ module.exports = function(Topics) { return callback(); } + var now = Date.now(); + var scores = tids.map(function(tid) { + return now; + }); + async.parallel({ markRead: function(next) { db.sortedSetAdd('uid:' + uid + ':tids_read', scores, tids, next);