Skip to content

Node.js based forum software built for the modern web

small cleanup to postSummary

barisusaklid97af5020abe
diff --git a/src/plugins.js b/src/plugins.js
index 5ca41bd353..669c3e65b1 100644
--- a/src/plugins.js
+++ b/src/plugins.js
@@ -263,7 +263,7 @@ var fs = require('fs'),
async.each(languages, function(pathToLang, next) {
fs.readFile(pathToLang, function(err, file) {
try {
- var json = JSON.parse(file.toString());
+ var json = JSON.parse(file.toString());
} catch (err) {
winston.error('[plugins] Unable to parse custom language file: ' + pathToLang + '\r\n' + err.stack);
return next(err);
diff --git a/src/posts.js b/src/posts.js
index 749adca82f..c7861c8364 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -338,19 +338,15 @@ var async = require('async'),
results.topics = toObject('tid', results.topicsAndCategories.topics);
results.categories = toObject('cid', results.topicsAndCategories.categories);
- for(var i=0; i<posts.length; ++i) {
- if (!utils.isNumber(results.indices[i])) {
- posts[i].index = 1;
- } else {
- posts[i].index = parseInt(results.indices[i], 10) + 2;
- }
+ for (var i=0; i<posts.length; ++i) {
+ posts[i].index = utils.isNumber(results.indices[i]) ? parseInt(results.indices[i], 10) + 2 : 1;
}
- async.map(posts, function(post, next) {
- if (parseInt(results.topics[post.tid].deleted, 10) === 1) {
- return next();
- }
+ posts = posts.filter(function(post) {
+ return parseInt(results.topics[post.tid].deleted, 10) !== 1;
+ });
+ async.map(posts, function(post, next) {
post.user = results.users[post.uid];
post.topic = results.topics[post.tid];
post.category = results.categories[post.topic.cid];
@@ -376,17 +372,7 @@ var async = require('async'),
next(null, post);
});
- }, function(err, posts) {
- if (err) {
- return callback(err);
- }
-
- posts = posts.filter(function(post) {
- return !!post;
- });
-
- callback(null, posts);
- });
+ }, callback);
});
});
};