mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #3150
This commit is contained in:
@@ -159,7 +159,11 @@ var async = require('async'),
|
||||
category.disabled = parseInt(category.disabled, 10) === 1;
|
||||
category.icon = category.icon || 'hidden';
|
||||
if (category.hasOwnProperty('post_count')) {
|
||||
category.post_count = category.post_count || 0;
|
||||
category.post_count = category.totalPostCount = category.post_count || 0;
|
||||
}
|
||||
|
||||
if (category.hasOwnProperty('topic_count')) {
|
||||
category.topic_count = category.totalTopicCount = category.topic_count || 0;
|
||||
}
|
||||
|
||||
if (category.description) {
|
||||
@@ -250,18 +254,23 @@ var async = require('async'),
|
||||
};
|
||||
|
||||
function calculateTopicPostCount(category) {
|
||||
if (!Array.isArray(category.children) || !category.children.length) {
|
||||
if (!category) {
|
||||
return;
|
||||
}
|
||||
var postCount = parseInt(category.post_count, 10) || 0;
|
||||
var topicCount = parseInt(category.topic_count, 10) || 0;
|
||||
if (!Array.isArray(category.children) || !category.children.length) {
|
||||
category.totalPostCount = postCount;
|
||||
category.totalTopicCount = topicCount;
|
||||
return;
|
||||
}
|
||||
|
||||
category.children.forEach(function(child) {
|
||||
postCount += parseInt(child.post_count, 10) || 0;
|
||||
topicCount += parseInt(child.topic_count, 10) || 0;
|
||||
});
|
||||
category.post_count = postCount;
|
||||
category.topic_count = topicCount;
|
||||
category.totalPostCount = postCount;
|
||||
category.totalTopicCount = topicCount;
|
||||
}
|
||||
|
||||
Categories.getParents = function(cids, callback) {
|
||||
|
||||
Reference in New Issue
Block a user