mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 10:57:58 +00:00
typeahead: Clean up variable names to follow snake_case convention.
This commit is contained in:
@@ -128,40 +128,44 @@ export function triage<T>(
|
|||||||
`matches` and then call the rest `rest`.
|
`matches` and then call the rest `rest`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const exactMatch = [];
|
const exact_matches = [];
|
||||||
const beginswithCaseSensitive = [];
|
const begins_with_case_sensitive_matches = [];
|
||||||
const beginswithCaseInsensitive = [];
|
const begins_with_case_insensitive_matches = [];
|
||||||
const noMatch = [];
|
const no_matches = [];
|
||||||
const lowerQuery = query ? query.toLowerCase() : "";
|
const lower_query = query ? query.toLowerCase() : "";
|
||||||
|
|
||||||
for (const obj of objs) {
|
for (const obj of objs) {
|
||||||
const item = get_item(obj);
|
const item = get_item(obj);
|
||||||
const lowerItem = item.toLowerCase();
|
const lower_item = item.toLowerCase();
|
||||||
|
|
||||||
if (lowerItem === lowerQuery) {
|
if (lower_item === lower_query) {
|
||||||
exactMatch.push(obj);
|
exact_matches.push(obj);
|
||||||
} else if (item.startsWith(query)) {
|
} else if (item.startsWith(query)) {
|
||||||
beginswithCaseSensitive.push(obj);
|
begins_with_case_sensitive_matches.push(obj);
|
||||||
} else if (lowerItem.startsWith(lowerQuery)) {
|
} else if (lower_item.startsWith(lower_query)) {
|
||||||
beginswithCaseInsensitive.push(obj);
|
begins_with_case_insensitive_matches.push(obj);
|
||||||
} else {
|
} else {
|
||||||
noMatch.push(obj);
|
no_matches.push(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sorting_comparator) {
|
if (sorting_comparator) {
|
||||||
const non_exact_sorted_matches = [
|
const non_exact_sorted_matches = [
|
||||||
...beginswithCaseSensitive,
|
...begins_with_case_sensitive_matches,
|
||||||
...beginswithCaseInsensitive,
|
...begins_with_case_insensitive_matches,
|
||||||
].sort(sorting_comparator);
|
].sort(sorting_comparator);
|
||||||
return {
|
return {
|
||||||
matches: [...exactMatch.sort(sorting_comparator), ...non_exact_sorted_matches],
|
matches: [...exact_matches.sort(sorting_comparator), ...non_exact_sorted_matches],
|
||||||
rest: noMatch.sort(sorting_comparator),
|
rest: no_matches.sort(sorting_comparator),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
matches: [...exactMatch, ...beginswithCaseSensitive, ...beginswithCaseInsensitive],
|
matches: [
|
||||||
rest: noMatch,
|
...exact_matches,
|
||||||
|
...begins_with_case_sensitive_matches,
|
||||||
|
...begins_with_case_insensitive_matches,
|
||||||
|
],
|
||||||
|
rest: no_matches,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user