empty array if not topics in catgory

This commit is contained in:
Baris Soner Usakli
2014-02-26 17:34:02 -05:00
parent d5268f5497
commit ad37715972

View File

@@ -93,23 +93,23 @@ var db = require('./database'),
topics.getTopicsByTids(tids, cid, uid, next);
},
function(topics, next) {
if (topics && topics.length > 0) {
db.sortedSetRevRank('categories:' + cid + ':tid', topics[topics.length - 1].tid, function(err, rank) {
if(err) {
return next(err);
}
next(null, {
topics: topics,
nextStart: parseInt(rank, 10) + 1
});
});
} else {
next(null, {
topics: topics,
if (!topics || !topics.length) {
return next(null, {
topics: [],
nextStart: 1
});
}
db.sortedSetRevRank('categories:' + cid + ':tid', topics[topics.length - 1].tid, function(err, rank) {
if(err) {
return next(err);
}
next(null, {
topics: topics,
nextStart: parseInt(rank, 10) + 1
});
});
}
], callback);
};