mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
#2886 Check subcategories when showing category recent topics
This commit is contained in:
@@ -61,7 +61,8 @@ module.exports = function(Categories) {
|
|||||||
|
|
||||||
function assignPostsToCategory(category, posts) {
|
function assignPostsToCategory(category, posts) {
|
||||||
category.posts = posts.filter(function(post) {
|
category.posts = posts.filter(function(post) {
|
||||||
return post.category && parseInt(post.category.cid, 10) === parseInt(category.cid, 10);
|
return !!(post.category && (parseInt(post.category.cid, 10) === parseInt(category.cid, 10)
|
||||||
|
) || (parseInt(post.category.parentCid, 10) === parseInt(category.cid, 10)));
|
||||||
}).sort(function(a, b) {
|
}).sort(function(a, b) {
|
||||||
return b.timestamp - a.timestamp;
|
return b.timestamp - a.timestamp;
|
||||||
}).slice(0, parseInt(category.numRecentReplies, 10));
|
}).slice(0, parseInt(category.numRecentReplies, 10));
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ module.exports = function(Posts) {
|
|||||||
return topic && array.indexOf(topic) === index;
|
return topic && array.indexOf(topic) === index;
|
||||||
});
|
});
|
||||||
|
|
||||||
categories.getMultipleCategoryFields(cids, ['cid', 'name', 'icon', 'slug'], function(err, categories) {
|
categories.getMultipleCategoryFields(cids, ['cid', 'name', 'icon', 'slug', 'parentCid'], function(err, categories) {
|
||||||
callback(err, {topics: topics, categories: categories});
|
callback(err, {topics: topics, categories: categories});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user