mirror of https://github.com/zulip/zulip.git
typeahead: Do not prioritize exact name matches for users.
As discussed in the comment, this resulted in the many inactive users
in chat.zulip.org with "Tim" as their full display name from being
incorrectly prioritized over me in a stream where I've been active;
and this class of problem seems like it will be common in large open
communities.
This reverts a portion of 4dc1b2f812
,
with explanatory comments for why this behavior is preferred.
The stream name changes in the original PR remain very helpful.
This commit is contained in:
parent
0b7dd46530
commit
18e2cee572
|
@ -387,21 +387,12 @@ export function sort_recipients({
|
|||
}
|
||||
}
|
||||
|
||||
// Push exact matches to top. We could do by passing the
|
||||
// comparator parameter to triage, but that would break the
|
||||
// optimization of only doing expensive sorting operations when
|
||||
// necessary.
|
||||
const exact_matches = [];
|
||||
const rest = [];
|
||||
for (const item of items) {
|
||||
if (item.full_name?.toLowerCase() === query.toLowerCase()) {
|
||||
exact_matches.push(item);
|
||||
} else {
|
||||
rest.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
return [...exact_matches, ...rest].slice(0, max_num_items);
|
||||
// We don't push exact matches to the top, like we do with other
|
||||
// typeaheads, because in open organizations, it's not uncommon to
|
||||
// have a bunch of inactive users with display names that are just
|
||||
// FirstName, which we don't want to artificially prioritize over the
|
||||
// the lone active user whose name is FirstName LastName.
|
||||
return items.slice(0, max_num_items);
|
||||
}
|
||||
|
||||
function slash_command_comparator(slash_command_a, slash_command_b) {
|
||||
|
|
|
@ -1784,8 +1784,8 @@ test("PM recipients sorted according to stream / topic being viewed", ({override
|
|||
(stream_id, user_id) => stream_id === denmark_stream.stream_id && user_id === alice.user_id,
|
||||
);
|
||||
|
||||
// When viewing denmark stream to which alice is subscribed, ali is still
|
||||
// 1st by virtue of the name being an exact match with the query.
|
||||
// When viewing denmark stream to which alice is subscribed, ali is not
|
||||
// 1st despite having an exact name match with the query.
|
||||
results = ct.get_pm_people("ali");
|
||||
assert.deepEqual(results, [ali, alice]);
|
||||
assert.deepEqual(results, [alice, ali]);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue