fix: only return necessary data for categories

This commit is contained in:
Barış Soner Uşaklı
2019-09-20 02:12:15 -04:00
parent e0fec86628
commit 307abaa8cc
2 changed files with 10 additions and 8 deletions

View File

@@ -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]]' },