From 038a833125105e20678458d4571d1b6231f696ee Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 24 Mar 2014 21:53:14 -0400 Subject: [PATCH] check to see if there are topics --- src/topics/unread.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/topics/unread.js b/src/topics/unread.js index f2e7f0dff7..a3e82145e6 100644 --- a/src/topics/unread.js +++ b/src/topics/unread.js @@ -76,13 +76,16 @@ module.exports = function(Topics) { topics: [] }; - function sendUnreadTopics(topicIds) { - - Topics.getTopicsByTids(topicIds, uid, function(err, topicData) { - if(err) { + function sendUnreadTopics(tids) { + Topics.getTopicsByTids(tids, uid, function(err, topicData) { + if (err) { return callback(err); } + if (!Array.isArray(topicData) || !topicData.length) { + return callback(null, unreadTopics); + } + db.sortedSetRevRank('topics:recent', topicData[topicData.length - 1].tid, function(err, rank) { if(err) { return callback(err);