From c47fc36201620178064ea6cab489894c50d2af9e Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 10 Jan 2020 14:15:43 +0000 Subject: [PATCH] refactor: Extract filter_persons. This extraction will make sense in the next commit. --- static/js/composebox_typeahead.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index af41ea905d..b71873cf36 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -485,20 +485,23 @@ exports.get_person_suggestions = function (query, opts) { 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(); - 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()); - } - - const filtered_persons = _.filter(persons, person_matcher); + const filtered_persons = filter_persons(all_persons); let groups;