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
v1.18.x
aStonedPenguin 7 years ago 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);

Loading…
Cancel
Save