Skip to content

Node.js based forum software built for the modern web

closes #2658

barisusaklic33b369858a5
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);