Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

refactor: Rename `query_matches_string` to `query_matches_string_in_order`.

N-Shar-mac503a846babb
diff --git a/web/shared/src/typeahead.ts b/web/shared/src/typeahead.ts
index 8b7661bf729..57b6fc3c303 100644
--- a/web/shared/src/typeahead.ts
+++ b/web/shared/src/typeahead.ts
@@ -54,7 +54,7 @@ export function remove_diacritics(s: string): string {
// * query is the user-entered search query
// * source_str is the string we're matching in, e.g. a user's name
// * split_char is the separator for this syntax (e.g. ' ').
-export function query_matches_string(
+export function query_matches_string_in_order(
query: string,
source_str: string,
split_char: string,
@@ -111,7 +111,7 @@ export function get_emoji_matcher(query: string): (emoji: Emoji) => boolean {
const matches_emoji_literal =
emoji.reaction_type === "unicode_emoji" &&
parse_unicode_emoji_code(emoji.emoji_code) === query;
- return matches_emoji_literal || query_matches_string(query, emoji.emoji_name, "_");
+ return matches_emoji_literal || query_matches_string_in_order(query, emoji.emoji_name, "_");
};
}
diff --git a/web/src/composebox_typeahead.js b/web/src/composebox_typeahead.js
index 5a3a20bd7f0..070bf4f98d3 100644
--- a/web/src/composebox_typeahead.js
+++ b/web/src/composebox_typeahead.js
@@ -91,14 +91,14 @@ function get_language_matcher(query) {
export function query_matches_person(query, person) {
return (
- typeahead.query_matches_string(query, person.full_name, " ") ||
+ typeahead.query_matches_string_in_order(query, person.full_name, " ") ||
(Boolean(person.delivery_email) &&
- typeahead.query_matches_string(query, people.get_visible_email(person), " "))
+ typeahead.query_matches_string_in_order(query, people.get_visible_email(person), " "))
);
}
export function query_matches_name(query, user_group_or_stream) {
- return typeahead.query_matches_string(query, user_group_or_stream.name, " ");
+ return typeahead.query_matches_string_in_order(query, user_group_or_stream.name, " ");
}
function get_stream_or_user_group_matcher(query) {
@@ -115,8 +115,8 @@ function get_slash_matcher(query) {
return function (item) {
return (
- typeahead.query_matches_string(query, item.name, " ") ||
- typeahead.query_matches_string(query, item.aliases, " ")
+ typeahead.query_matches_string_in_order(query, item.name, " ") ||
+ typeahead.query_matches_string_in_order(query, item.aliases, " ")
);
};
}
@@ -129,7 +129,7 @@ function get_topic_matcher(query) {
topic,
};
- return typeahead.query_matches_string(query, obj.topic, " ");
+ return typeahead.query_matches_string_in_order(query, obj.topic, " ");
};
}