mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 07:26:13 +02:00
use includes instead of indexOf
use _.uniq instead of filter&indexOf
This commit is contained in:
@@ -19,7 +19,7 @@ module.exports = function (Groups) {
|
||||
});
|
||||
|
||||
var ephemeralIdx = groupNames.reduce(function (memo, cur, idx) {
|
||||
if (Groups.ephemeralGroups.indexOf(cur) !== -1) {
|
||||
if (Groups.ephemeralGroups.includes(cur)) {
|
||||
memo.push(idx);
|
||||
}
|
||||
return memo;
|
||||
|
||||
@@ -265,14 +265,14 @@ module.exports = function (Groups) {
|
||||
},
|
||||
function (groupNames, next) {
|
||||
groupNames = Groups.removeEphemeralGroups(groupNames);
|
||||
if (groupNames.length === 0) {
|
||||
if (!groupNames.length) {
|
||||
return callback(null, false);
|
||||
}
|
||||
|
||||
Groups.isMemberOfGroups(uid, groupNames, next);
|
||||
},
|
||||
function (isMembers, next) {
|
||||
next(null, isMembers.indexOf(true) !== -1);
|
||||
next(null, isMembers.includes(true));
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = function (Groups) {
|
||||
// Ephemeral groups and the registered-users groups are searchable
|
||||
groupNames = Groups.ephemeralGroups.concat(groupNames).concat('registered-users');
|
||||
groupNames = groupNames.filter(function (name) {
|
||||
return name.toLowerCase().indexOf(query) !== -1 && name !== 'administrators' && !Groups.isPrivilegeGroup(name);
|
||||
return name.toLowerCase().includes(query) && name !== 'administrators' && !Groups.isPrivilegeGroup(name);
|
||||
});
|
||||
groupNames = groupNames.slice(0, 100);
|
||||
Groups.getGroupsData(groupNames, next);
|
||||
|
||||
Reference in New Issue
Block a user