v1.18.x
Barış Soner Uşaklı 6 years ago
parent a662f118a5
commit 428f587cbe

@ -70,6 +70,8 @@ define('forum/groups/list', ['forum/infinitescroll', 'benchpress'], function (in
options: { options: {
sort: sortEl.val(), sort: sortEl.val(),
filterHidden: true, filterHidden: true,
showMembers: true,
hideEphemeralGroups: true,
}, },
}, function (err, groups) { }, function (err, groups) {
if (err) { if (err) {

@ -105,7 +105,7 @@ Groups.getGroupsAndMembers = function (groupNames, callback) {
data.groups.forEach(function (group, index) { data.groups.forEach(function (group, index) {
if (group) { if (group) {
group.members = data.members[index] || []; group.members = data.members[index] || [];
group.truncated = group.memberCount > data.members.length; group.truncated = group.memberCount > group.members.length;
} }
}); });
next(null, data.groups); next(null, data.groups);

@ -15,20 +15,23 @@ module.exports = function (Groups) {
async.waterfall([ async.waterfall([
async.apply(db.getSortedSetRange, 'groups:createtime', 0, -1), async.apply(db.getSortedSetRange, 'groups:createtime', 0, -1),
function (groupNames, next) { function (groupNames, next) {
// Ephemeral groups and the registered-users groups are searchable if (!options.hideEphemeralGroups) {
groupNames = Groups.ephemeralGroups.concat(groupNames); groupNames = Groups.ephemeralGroups.concat(groupNames);
}
groupNames = groupNames.filter(function (name) { groupNames = groupNames.filter(function (name) {
return name.toLowerCase().includes(query) && name !== 'administrators' && !Groups.isPrivilegeGroup(name); return name.toLowerCase().includes(query) && name !== 'administrators' && !Groups.isPrivilegeGroup(name);
}); });
groupNames = groupNames.slice(0, 100); groupNames = groupNames.slice(0, 100);
Groups.getGroupsData(groupNames, next); if (options.showMembers) {
Groups.getGroupsAndMembers(groupNames, next);
} else {
Groups.getGroupsData(groupNames, next);
}
}, },
function (groupsData, next) { function (groupsData, next) {
groupsData = groupsData.filter(Boolean); groupsData = groupsData.filter(Boolean);
if (options.filterHidden) { if (options.filterHidden) {
groupsData = groupsData.filter(function (group) { groupsData = groupsData.filter(group => !group.hidden);
return !group.hidden;
});
} }
Groups.sort(options.sort, groupsData, next); Groups.sort(options.sort, groupsData, next);

Loading…
Cancel
Save