mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
Add unread-class to category children (#6071)
* Add unread-class to category children * unused variables * Move child unread-class to a better place * comma? ¯\_(ツ)_/¯ * feedback
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
c47c47f7e3
commit
610a1c943f
@@ -153,10 +153,10 @@ Categories.getCategories = function (cids, uid, callback) {
|
||||
uid = parseInt(uid, 10);
|
||||
results.categories.forEach(function (category, i) {
|
||||
if (category) {
|
||||
category['unread-class'] = (parseInt(category.topic_count, 10) === 0 || (results.hasRead[i] && uid !== 0)) ? '' : 'unread';
|
||||
category.children = results.children[i];
|
||||
category.parent = results.parents[i] || undefined;
|
||||
category.tagWhitelist = results.tagWhitelist[i];
|
||||
category['unread-class'] = (parseInt(category.topic_count, 10) === 0 || (results.hasRead[i] && uid !== 0)) ? '' : 'unread';
|
||||
calculateTopicPostCount(category);
|
||||
}
|
||||
});
|
||||
@@ -259,9 +259,25 @@ function getChildrenRecursive(category, uid, callback) {
|
||||
}
|
||||
Categories.getCategoriesData(children, next);
|
||||
},
|
||||
function (childrenData, next) {
|
||||
childrenData = childrenData.filter(Boolean);
|
||||
category.children = childrenData;
|
||||
function (children, next) {
|
||||
children = children.filter(Boolean);
|
||||
category.children = children;
|
||||
|
||||
var cids = children.map(function (child) {
|
||||
return child.cid;
|
||||
});
|
||||
|
||||
Categories.hasReadCategories(cids, uid, next);
|
||||
},
|
||||
function (hasRead, next) {
|
||||
hasRead.forEach(function (read, i) {
|
||||
var child = category.children[i];
|
||||
child['unread-class'] = (parseInt(child.topic_count, 10) === 0 || (read && uid !== 0)) ? '' : 'unread';
|
||||
});
|
||||
|
||||
next();
|
||||
},
|
||||
function (next) {
|
||||
async.each(category.children, function (child, next) {
|
||||
getChildrenRecursive(child, uid, next);
|
||||
}, next);
|
||||
|
||||
Reference in New Issue
Block a user