mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
typeahead: Fix '@topic' not present when stream wildcard suggested.
Earlier, we suggested only the first matching wildcard mention, irrespective of how many equivalent wildcard mentions match. That logic leads to the exclusion of '@topic' suggestion whenever a stream wildcard is suggested, which is not correct as stream wildcards and topic wildcard are not equivalent. This commit updates the logic to make the behavior of suggesting only the first match valid for stream wildcard mentions only.
This commit is contained in:
committed by
Tim Abbott
parent
fb9e258a65
commit
c76b3acce7
@@ -398,15 +398,16 @@ export function sort_recipients({
|
||||
}
|
||||
}
|
||||
|
||||
// We suggest only the first matching wildcard mention,
|
||||
// irrespective of how many equivalent wildcard mentions match.
|
||||
// We suggest only the first matching stream wildcard mention,
|
||||
// irrespective of how many equivalent stream wildcard mentions match.
|
||||
const recipients = [];
|
||||
let wildcard_mention_included = false;
|
||||
let stream_wildcard_mention_included = false;
|
||||
for (const item of items) {
|
||||
if (!item.is_broadcast || !wildcard_mention_included) {
|
||||
const topic_wildcard_mention = item.email === "topic";
|
||||
if (!item.is_broadcast || topic_wildcard_mention || !stream_wildcard_mention_included) {
|
||||
recipients.push(item);
|
||||
if (item.is_broadcast) {
|
||||
wildcard_mention_included = true;
|
||||
if (item.is_broadcast && !topic_wildcard_mention) {
|
||||
stream_wildcard_mention_included = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1753,8 +1753,8 @@ test("typeahead_results", () => {
|
||||
// Verify we're not matching on a terms that only appear in the description.
|
||||
assert_mentions_matches("characters of", []);
|
||||
|
||||
// Verify we suggest only the first matching wildcard mention,
|
||||
// irrespective of how many equivalent wildcard mentions match.
|
||||
// Verify we suggest only the first matching stream wildcard mention,
|
||||
// irrespective of how many equivalent stream wildcard mentions match.
|
||||
const mention_everyone = ct.broadcast_mentions()[1];
|
||||
// Here, we suggest only "everyone" instead of both the matching
|
||||
// "everyone" and "stream" wildcard mentions.
|
||||
@@ -1771,6 +1771,12 @@ test("typeahead_results", () => {
|
||||
call_center,
|
||||
]);
|
||||
|
||||
// Verify we suggest both 'the first matching stream wildcard' and
|
||||
// 'topic wildcard' mentions. Not only one matching wildcard mention.
|
||||
const mention_topic = ct.broadcast_mentions()[3];
|
||||
// Here, we suggest both "everyone" and "topic".
|
||||
assert_mentions_matches("o", [othello, mention_everyone, mention_topic, cordelia]);
|
||||
|
||||
// Autocomplete by slash commands.
|
||||
assert_slash_matches("me", [me_slash]);
|
||||
assert_slash_matches("dark", [dark_slash]);
|
||||
|
||||
Reference in New Issue
Block a user