Merge branch 'master' into acp-paper

v1.18.x
psychobunny 10 years ago
commit 48d61b8048

@ -93,16 +93,25 @@ module.exports = function(Categories) {
if (category.posts.length) { if (category.posts.length) {
return; return;
} }
var latestPost; var posts = [];
category.children.forEach(function(children) { getPostsRecursive(category, posts);
if (children.posts.length && (!latestPost || (latestPost && latestPost.timestamp < children.posts[0].timestamp))) {
latestPost = children.posts[0]; posts.sort(function(a, b) {
return b.timestamp - a.timestamp;
});
if (posts.length) {
category.posts = [posts[0]];
} }
}); });
if (latestPost) {
category.posts = [latestPost];
} }
function getPostsRecursive(category, posts) {
category.posts.forEach(function(p) {
posts.push(p);
});
category.children.forEach(function(child) {
getPostsRecursive(child, posts);
}); });
} }

Loading…
Cancel
Save