refactor: Extract filter_persons.

This extraction will make sense in the next commit.
This commit is contained in:
Steve Howell 2020-01-10 14:15:43 +00:00 committed by Tim Abbott
parent 9ed5545abb
commit c47fc36201
1 changed files with 16 additions and 13 deletions

View File

@ -485,20 +485,23 @@ exports.get_person_suggestions = function (query, opts) {
return query_matches_name_description(query, item); return query_matches_name_description(query, item);
}; };
function filter_persons(all_persons) {
let persons;
if (opts.filter_pills) {
persons = compose_pm_pill.filter_taken_users(all_persons);
} else {
persons = all_persons;
}
if (opts.want_broadcast) {
persons = persons.concat(exports.broadcast_mentions());
}
return _.filter(persons, person_matcher);
}
const all_persons = people.get_realm_persons(); const all_persons = people.get_realm_persons();
let persons; const filtered_persons = filter_persons(all_persons);
if (opts.filter_pills) {
persons = compose_pm_pill.filter_taken_users(all_persons);
} else {
persons = all_persons;
}
if (opts.want_broadcast) {
persons = persons.concat(exports.broadcast_mentions());
}
const filtered_persons = _.filter(persons, person_matcher);
let groups; let groups;