refactor: Rename query_matches_string to query_matches_string_in_order.

The function is renamed for clarity.

Prep commit for next commit which adds a similar function where order
does not matter.
This commit is contained in:
N-Shar-ma
2023-03-11 00:06:46 +05:30
committed by Tim Abbott
parent 5d83e53ca5
commit c503a846ba
2 changed files with 8 additions and 8 deletions

View File

@@ -54,7 +54,7 @@ export function remove_diacritics(s: string): string {
// * query is the user-entered search query // * query is the user-entered search query
// * source_str is the string we're matching in, e.g. a user's name // * 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. ' '). // * split_char is the separator for this syntax (e.g. ' ').
export function query_matches_string( export function query_matches_string_in_order(
query: string, query: string,
source_str: string, source_str: string,
split_char: string, split_char: string,
@@ -111,7 +111,7 @@ export function get_emoji_matcher(query: string): (emoji: Emoji) => boolean {
const matches_emoji_literal = const matches_emoji_literal =
emoji.reaction_type === "unicode_emoji" && emoji.reaction_type === "unicode_emoji" &&
parse_unicode_emoji_code(emoji.emoji_code) === query; 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, "_");
}; };
} }

View File

@@ -91,14 +91,14 @@ function get_language_matcher(query) {
export function query_matches_person(query, person) { export function query_matches_person(query, person) {
return ( return (
typeahead.query_matches_string(query, person.full_name, " ") || typeahead.query_matches_string_in_order(query, person.full_name, " ") ||
(Boolean(person.delivery_email) && (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) { 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) { function get_stream_or_user_group_matcher(query) {
@@ -115,8 +115,8 @@ function get_slash_matcher(query) {
return function (item) { return function (item) {
return ( return (
typeahead.query_matches_string(query, item.name, " ") || typeahead.query_matches_string_in_order(query, item.name, " ") ||
typeahead.query_matches_string(query, item.aliases, " ") typeahead.query_matches_string_in_order(query, item.aliases, " ")
); );
}; };
} }
@@ -129,7 +129,7 @@ function get_topic_matcher(query) {
topic, topic,
}; };
return typeahead.query_matches_string(query, obj.topic, " "); return typeahead.query_matches_string_in_order(query, obj.topic, " ");
}; };
} }