people: Don't refetch user when we already have it.

This commit is contained in:
evykassirer 2024-03-05 10:57:24 -08:00 committed by Tim Abbott
parent e965ed2eb8
commit af8263fb87
2 changed files with 1 additions and 14 deletions

View File

@ -1234,17 +1234,11 @@ export function filter_people_by_search_terms(
// Loop through users and populate filtered_users only
// if they include search_terms
for (const user of users) {
const person = get_by_email(user.email);
// Get person object (and ignore errors)
if (!person?.full_name) {
continue;
}
// Return user emails that include search terms
const match = matchers.some((matcher) => matcher(user));
if (match) {
filtered_users.set(person.user_id, true);
filtered_users.set(user.user_id, true);
}
}

View File

@ -758,13 +758,6 @@ test_people("filtered_users", () => {
filtered_people = people.filter_people_by_search_terms(users, ["ëm"]);
assert.equal(filtered_people.size, 1);
assert.ok(filtered_people.has(noah.user_id));
// Test filtering with undefined user
users.push(invalid_user);
filtered_people = people.filter_people_by_search_terms(users, ["ltorv"]);
assert.equal(filtered_people.size, 1);
assert.ok(filtered_people.has(linus.user_id));
});
test_people("multi_user_methods", () => {