Node.js based forum software built for the modern web
closes #2088
barisusakliaae7f2434d7e
diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.jsindex 97199e636e..a215a764d5 100644--- a/src/categories/recentreplies.js+++ b/src/categories/recentreplies.js@@ -25,7 +25,11 @@ module.exports = function(Categories) {};Categories.getRecentTopicReplies = function(categoryData, uid, callback) {+ if (!Array.isArray(categoryData) || !categoryData.length) {+ return callback(null, []);+ }async.map(categoryData, getRecentTopicPids, function(err, results) {+var pids = _.flatten(results);pids = pids.filter(function(pid, index, array) {diff --git a/src/controllers/index.js b/src/controllers/index.jsindex 97afb0d4e4..29c916a1cf 100644--- a/src/controllers/index.js+++ b/src/controllers/index.js@@ -68,13 +68,27 @@ Controllers.home = function(req, res, next) {if (err) {return next(err);}+ var childCategories = [];- // Remove child categories, as they don't belong on the home page- categoryData = categoryData.filter(function(categoryObj) {- return !categoryObj.parent;- });+ for(var i=categoryData.length - 1; i>=0; --i) {++ if (Array.isArray(categoryData[i].children) && categoryData[i].children.length) {+ childCategories.push.apply(childCategories, categoryData[i].children);+ }++ if (categoryData[i].parent) {+ categoryData.splice(i, 1);+ }+ }- categories.getRecentTopicReplies(categoryData, uid, function(err) {+ async.parallel([+ function(next) {+ categories.getRecentTopicReplies(categoryData, uid, next);+ },+ function(next) {+ categories.getRecentTopicReplies(childCategories, uid, next);+ }+ ], function(err) {next(err, categoryData);});});@@ -182,7 +196,7 @@ Controllers.confirmEmail = function(req, res, next) {Controllers.sitemap = function(req, res, next) {if (meta.config['feeds:disableSitemap'] === '1') {- return res.redirect(nconf.get('relative_path') + '/404')+ return res.redirect(nconf.get('relative_path') + '/404');}var sitemap = require('../sitemap.js');diff --git a/src/posts.js b/src/posts.jsindex 6eb1e9eae9..c0f0d91cb8 100644--- a/src/posts.js+++ b/src/posts.js@@ -221,6 +221,10 @@ var async = require('async'),options.stripTags = options.hasOwnProperty('stripTags') ? options.stripTags : false;options.parse = options.hasOwnProperty('parse') ? options.parse : true;+ if (!Array.isArray(pids) || !pids.length) {+ return callback(null, []);+ }+var keys = pids.map(function(pid) {return 'post:' + pid;});