added badge to header for unread topics count

This commit is contained in:
psychobunny
2013-08-22 00:08:11 +08:00
parent 746fa93c80
commit f1547a7b1f
6 changed files with 32 additions and 7 deletions

View File

@@ -128,11 +128,16 @@ marked.setOptions({
}
Topics.getTotalUnread = function(uid, callback) {
RDB.zcount('topics:recent', '-inf', '+inf', function(err, count) {
if (err) count = 0;
console.log(count);
RDB.zrevrange('topics:recent', 0, 21, function (err, tids) {
Topics.hasReadTopics(tids, uid, function(read) {
var unreadTids = tids.filter(function(tid, index, self) {
return read[index] === 0;
});
callback(count);
callback({
count: unreadTids.length
});
});
});
};