mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +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);
|
uid = parseInt(uid, 10);
|
||||||
results.categories.forEach(function (category, i) {
|
results.categories.forEach(function (category, i) {
|
||||||
if (category) {
|
if (category) {
|
||||||
category['unread-class'] = (parseInt(category.topic_count, 10) === 0 || (results.hasRead[i] && uid !== 0)) ? '' : 'unread';
|
|
||||||
category.children = results.children[i];
|
category.children = results.children[i];
|
||||||
category.parent = results.parents[i] || undefined;
|
category.parent = results.parents[i] || undefined;
|
||||||
category.tagWhitelist = results.tagWhitelist[i];
|
category.tagWhitelist = results.tagWhitelist[i];
|
||||||
|
category['unread-class'] = (parseInt(category.topic_count, 10) === 0 || (results.hasRead[i] && uid !== 0)) ? '' : 'unread';
|
||||||
calculateTopicPostCount(category);
|
calculateTopicPostCount(category);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -259,9 +259,25 @@ function getChildrenRecursive(category, uid, callback) {
|
|||||||
}
|
}
|
||||||
Categories.getCategoriesData(children, next);
|
Categories.getCategoriesData(children, next);
|
||||||
},
|
},
|
||||||
function (childrenData, next) {
|
function (children, next) {
|
||||||
childrenData = childrenData.filter(Boolean);
|
children = children.filter(Boolean);
|
||||||
category.children = childrenData;
|
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) {
|
async.each(category.children, function (child, next) {
|
||||||
getChildrenRecursive(child, uid, next);
|
getChildrenRecursive(child, uid, next);
|
||||||
}, next);
|
}, next);
|
||||||
|
|||||||
Reference in New Issue
Block a user