refactor: Extract get_message_people.

We'll use this in two places coming up, so it's
worth extracting, plus I wanted to add the
fairly lengthy comment here.  (Tim, feel free
to edit down the comment as you see fit).
This commit is contained in:
Steve Howell 2020-01-10 14:22:25 +00:00 committed by Tim Abbott
parent c47fc36201
commit 8f35700da8

View File

@ -778,15 +778,35 @@ exports.remove_diacritics = function (s) {
return s.normalize("NFKD").replace(unicode_marks, "");
};
exports.get_people_for_search_bar = function (query) {
const pred = exports.build_person_matcher(query);
exports.get_message_people = function () {
/*
message_people are roughly the people who have
actually sent messages that are currently
showing up on your feed. These people
are important--we give them preference
over other users in certain search
suggestions, since non-message-people are
presumably either not very active or
possibly subscribed to streams you don't
care about. message_people also includes
people whom you have sent PMs, but look
at the message_store code to see the precise
semantics
*/
const message_people = _.compact(
_.map(message_store.user_ids(), (user_id) => {
return people_by_user_id_dict.get(user_id);
})
);
return message_people;
};
exports.get_people_for_search_bar = function (query) {
const pred = exports.build_person_matcher(query);
const message_people = exports.get_message_people();
const small_results = _.filter(message_people, pred);
if (small_results.length >= 5) {