mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
fix: only return necessary data for categories
This commit is contained in:
@@ -341,9 +341,7 @@ Categories.buildForSelectCategories = function (categories) {
|
||||
category.depth = depth;
|
||||
categoriesData.push(category);
|
||||
if (Array.isArray(category.children)) {
|
||||
category.children.forEach(function (child) {
|
||||
recursive(child, categoriesData, ' ' + level, depth + 1);
|
||||
});
|
||||
category.children.forEach(child => recursive(child, categoriesData, ' ' + level, depth + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,9 +349,7 @@ Categories.buildForSelectCategories = function (categories) {
|
||||
|
||||
categories = categories.filter(category => category && !category.parentCid);
|
||||
|
||||
categories.forEach(function (category) {
|
||||
recursive(category, categoriesData, '', 0);
|
||||
});
|
||||
categories.forEach(category => recursive(category, categoriesData, '', 0));
|
||||
return categoriesData;
|
||||
};
|
||||
|
||||
|
||||
@@ -84,8 +84,14 @@ async function buildCategories(uid, searchOnly) {
|
||||
if (searchOnly) {
|
||||
return [];
|
||||
}
|
||||
let categoriesData = await categories.buildForSelect(uid, 'read');
|
||||
categoriesData = categoriesData.filter(category => category && !category.link);
|
||||
|
||||
const cids = await categories.getCidsByPrivilege('categories:cid', uid, 'read');
|
||||
let categoriesData = await categories.getCategoriesData(cids);
|
||||
categoriesData = categories.getTree(categoriesData);
|
||||
categoriesData = categories.buildForSelectCategories(categoriesData);
|
||||
|
||||
categoriesData = categoriesData.filter(category => category && !category.link)
|
||||
.map(category => ({ value: category.value, text: category.text }));
|
||||
return [
|
||||
{ value: 'all', text: '[[unread:all_categories]]' },
|
||||
{ value: 'watched', text: '[[category:watched-categories]]' },
|
||||
|
||||
Reference in New Issue
Block a user