Filter group candidates before mapping

This commit is contained in:
Cohee 2023-08-19 03:22:10 +03:00
parent 1305f9dc4c
commit 3019b889cd

View File

@ -939,8 +939,9 @@ function getGroupCharacters({ doFilter, onlyMembers } = {}) {
}
const thisGroup = openGroupId && groups.find((x) => x.id == openGroupId);
let candidates = characters.map((x, index) => ({ item: x, id: index, type: 'character' }));
candidates = candidates.filter((x) => isGroupMember(thisGroup, x.item.avatar) == onlyMembers);
let candidates = characters
.filter((x) => isGroupMember(thisGroup, x.avatar) == onlyMembers)
.map((x, index) => ({ item: x, id: index, type: 'character' }));
if (onlyMembers) {
candidates.sort(sortMembersFn);