Skip to content

Node.js based forum software built for the modern web

empty array if not topics in catgory

Baris Soner Usakliad3771597283
diff --git a/src/categories.js b/src/categories.js
index 2433953e35..cb81add98b 100644
--- a/src/categories.js
+++ b/src/categories.js
@@ -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
- });
+ if (!topics || !topics.length) {
+ return next(null, {
+ topics: [],
+ nextStart: 1
});
- } else {
+ }
+
+ db.sortedSetRevRank('categories:' + cid + ':tid', topics[topics.length - 1].tid, function(err, rank) {
+ if(err) {
+ return next(err);
+ }
+
next(null, {
topics: topics,
- nextStart: 1
+ nextStart: parseInt(rank, 10) + 1
});
- }
+ });
}
], callback);
};