mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
dont use indexOf in map
This commit is contained in:
@@ -158,9 +158,7 @@ Categories.getCategories = function (cids, uid, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Categories.getTagWhitelist = function (cids, callback) {
|
Categories.getTagWhitelist = function (cids, callback) {
|
||||||
var keys = cids.map(function (cid) {
|
const keys = cids.map(cid => 'cid:' + cid + ':tag:whitelist');
|
||||||
return 'cid:' + cid + ':tag:whitelist';
|
|
||||||
});
|
|
||||||
db.getSortedSetsMembers(keys, callback);
|
db.getSortedSetsMembers(keys, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -206,9 +204,8 @@ Categories.getParents = function (cids, callback) {
|
|||||||
Categories.getCategoriesData(parentCids, next);
|
Categories.getCategoriesData(parentCids, next);
|
||||||
},
|
},
|
||||||
function (parentData, next) {
|
function (parentData, next) {
|
||||||
parentData = categoriesData.map(function (category) {
|
const cidToParent = _.zipObject(parentCids, parentData);
|
||||||
return parentData[parentCids.indexOf(category.parentCid)];
|
parentData = categoriesData.map(category => cidToParent[category.parentCid]);
|
||||||
});
|
|
||||||
next(null, parentData);
|
next(null, parentData);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
@@ -228,9 +225,7 @@ Categories.getChildren = function (cids, uid, callback) {
|
|||||||
getChildrenRecursive(category, uid, next);
|
getChildrenRecursive(category, uid, next);
|
||||||
});
|
});
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
callback(err, categories.map(function (c) {
|
callback(err, categories.map(c => c && c.children));
|
||||||
return c && c.children;
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -386,9 +381,7 @@ Categories.filterIgnoringUids = function (cid, uids, callback) {
|
|||||||
db.isSortedSetMembers('cid:' + cid + ':ignorers', uids, next);
|
db.isSortedSetMembers('cid:' + cid + ':ignorers', uids, next);
|
||||||
},
|
},
|
||||||
function (isIgnoring, next) {
|
function (isIgnoring, next) {
|
||||||
var readingUids = uids.filter(function (uid, index) {
|
const readingUids = uids.filter((uid, index) => uid && !isIgnoring[index]);
|
||||||
return uid && !isIgnoring[index];
|
|
||||||
});
|
|
||||||
next(null, readingUids);
|
next(null, readingUids);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user