empty array if not topics in catgory

v1.18.x
Baris Soner Usakli 11 years ago
parent d5268f5497
commit ad37715972

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

Loading…
Cancel
Save