From 8f35700da8c9d3edf35eacbfab8efc2d8e4bdf72 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 10 Jan 2020 14:22:25 +0000 Subject: [PATCH] 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). --- static/js/people.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/static/js/people.js b/static/js/people.js index d35c75b4db..00916df56e 100644 --- a/static/js/people.js +++ b/static/js/people.js @@ -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) {