Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
composebox_typeahead: Use query_matches_group_name to match group.
Sahil Batra053686669ad8
diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.tsindex 4147b9156bd..1f790f580e1 100644--- a/web/src/composebox_typeahead.ts+++ b/web/src/composebox_typeahead.ts@@ -179,14 +179,12 @@ export function get_language_matcher(query: string): (language: string) => boole};}-export function get_stream_or_user_group_matcher(- query: string,-): (user_group_or_stream: UserGroupPillData | StreamPillData) => boolean {+export function get_stream_matcher(query: string): (stream: StreamPillData) => boolean {// Case-insensitive.query = typeahead.clean_query_lowercase(query);- return function (user_group_or_stream: UserGroupPillData | StreamPillData) {- return typeahead_helper.query_matches_name(query, user_group_or_stream);+ return function (stream: StreamPillData) {+ return typeahead_helper.query_matches_stream_name(query, stream);};}@@ -669,7 +667,7 @@ export function get_person_suggestions(}));const filtered_groups = group_pill_data.filter((item) =>- typeahead_helper.query_matches_name(query, item),+ typeahead_helper.query_matches_group_name(query, item),);/*@@ -897,7 +895,7 @@ export function get_candidates(...sub,type: "stream",}));- const matcher = get_stream_or_user_group_matcher(token);+ const matcher = get_stream_matcher(token);const matches = candidate_list.filter((item) => matcher(item));return typeahead_helper.sort_streams(matches, token);}diff --git a/web/src/typeahead_helper.ts b/web/src/typeahead_helper.tsindex 5874763f9ac..80b505a0295 100644--- a/web/src/typeahead_helper.ts+++ b/web/src/typeahead_helper.ts@@ -665,11 +665,8 @@ export function query_matches_person(return false;}-export function query_matches_name(- query: string,- user_group_or_stream: UserGroupPillData | StreamPillData,-): boolean {- return typeahead.query_matches_string_in_order(query, user_group_or_stream.name, " ");+export function query_matches_stream_name(query: string, stream: StreamPillData): boolean {+ return typeahead.query_matches_string_in_order(query, stream.name, " ");}export function query_matches_group_name(query: string, user_group: UserGroupPillData): boolean {diff --git a/web/tests/composebox_typeahead.test.js b/web/tests/composebox_typeahead.test.jsindex d4fcccff697..9881aa05d33 100644--- a/web/tests/composebox_typeahead.test.js+++ b/web/tests/composebox_typeahead.test.js@@ -1166,7 +1166,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {assert.equal(matcher(make_emoji(emoji_tada)), true);assert.equal(matcher(make_emoji(emoji_moneybag)), false);- matcher = ct.get_stream_or_user_group_matcher("swed");+ matcher = ct.get_stream_matcher("swed");assert.equal(matcher(sweden_stream), true);assert.equal(matcher(denmark_stream), false);@@ -2022,7 +2022,7 @@ test("typeahead_results", () => {assert.deepEqual(returned, expected);}function assert_stream_matches(input, expected) {- const matcher = ct.get_stream_or_user_group_matcher(input);+ const matcher = ct.get_stream_matcher(input);const returned = stream_list.filter((item) => matcher(item));assert.deepEqual(returned, expected);}