mobile sharing: Extract shared/js/typeahead.js.

This extracts get_emoji_matcher and all the
functions it depended on, most of which were
in composebox_typeahead.js.

We also move remove_diacritics out of the people
module.

This is the first major step for #13728.
This commit is contained in:
Steve Howell
2020-01-26 13:21:13 +00:00
committed by Tim Abbott
parent c2ab63094d
commit 4125eb28fd
4 changed files with 94 additions and 91 deletions

View File

@@ -1,6 +1,7 @@
require("unorm"); // String.prototype.normalize polyfill for IE11
const IntDict = require('./int_dict').IntDict;
const FoldDict = require('./fold_dict').FoldDict;
const typeahead = require("../shared/js/typeahead");
let people_dict;
let people_by_name_dict;
@@ -771,12 +772,6 @@ exports.incr_recipient_count = function (user_id) {
pm_recipient_count_dict.set(user_id, old_count + 1);
};
const unicode_marks = /\p{M}/gu;
exports.remove_diacritics = function (s) {
return s.normalize("NFKD").replace(unicode_marks, "");
};
exports.get_message_people = function () {
/*
message_people are roughly the people who have
@@ -824,7 +819,7 @@ exports.build_termlet_matcher = function (termlet) {
let full_name = user.full_name;
if (is_ascii) {
// Only ignore diacritics if the query is plain ascii
full_name = exports.remove_diacritics(full_name);
full_name = typeahead.remove_diacritics(full_name);
}
const names = full_name.toLowerCase().split(' ');