mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
small cleanup to postSummary
This commit is contained in:
28
src/posts.js
28
src/posts.js
@@ -338,19 +338,15 @@ var async = require('async'),
|
|||||||
results.topics = toObject('tid', results.topicsAndCategories.topics);
|
results.topics = toObject('tid', results.topicsAndCategories.topics);
|
||||||
results.categories = toObject('cid', results.topicsAndCategories.categories);
|
results.categories = toObject('cid', results.topicsAndCategories.categories);
|
||||||
|
|
||||||
for(var i=0; i<posts.length; ++i) {
|
for (var i=0; i<posts.length; ++i) {
|
||||||
if (!utils.isNumber(results.indices[i])) {
|
posts[i].index = utils.isNumber(results.indices[i]) ? parseInt(results.indices[i], 10) + 2 : 1;
|
||||||
posts[i].index = 1;
|
|
||||||
} else {
|
|
||||||
posts[i].index = parseInt(results.indices[i], 10) + 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
posts = posts.filter(function(post) {
|
||||||
|
return parseInt(results.topics[post.tid].deleted, 10) !== 1;
|
||||||
|
});
|
||||||
|
|
||||||
async.map(posts, function(post, next) {
|
async.map(posts, function(post, next) {
|
||||||
if (parseInt(results.topics[post.tid].deleted, 10) === 1) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
|
|
||||||
post.user = results.users[post.uid];
|
post.user = results.users[post.uid];
|
||||||
post.topic = results.topics[post.tid];
|
post.topic = results.topics[post.tid];
|
||||||
post.category = results.categories[post.topic.cid];
|
post.category = results.categories[post.topic.cid];
|
||||||
@@ -376,17 +372,7 @@ var async = require('async'),
|
|||||||
|
|
||||||
next(null, post);
|
next(null, post);
|
||||||
});
|
});
|
||||||
}, function(err, posts) {
|
}, callback);
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
posts = posts.filter(function(post) {
|
|
||||||
return !!post;
|
|
||||||
});
|
|
||||||
|
|
||||||
callback(null, posts);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user