Fallback to emoji-datasource for unlocalized emoji
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
0607f01540
commit
48b78e7e35
3 changed files with 34 additions and 6 deletions
|
@ -37,10 +37,13 @@ export type FunEmojiSearch = (
|
|||
) => ReadonlyArray<FunEmojiSearchResult>;
|
||||
|
||||
export function createFunEmojiSearchIndex(
|
||||
localeEmojiList: LocaleEmojiListType
|
||||
localeEmojiList: LocaleEmojiListType,
|
||||
defaultSearchIndex: ReadonlyArray<FunEmojiSearchIndexEntry> = []
|
||||
): FunEmojiSearchIndex {
|
||||
const results: Array<FunEmojiSearchIndexEntry> = [];
|
||||
|
||||
const localizedKeys = new Set<string>();
|
||||
|
||||
for (const localeEmoji of localeEmojiList) {
|
||||
if (!isEmojiParentValue(localeEmoji.emoji)) {
|
||||
// Skipping unknown emoji, most likely apple doesn't support it
|
||||
|
@ -54,6 +57,7 @@ export function createFunEmojiSearchIndex(
|
|||
|
||||
const parentKey = getEmojiParentKeyByValue(localeEmoji.emoji);
|
||||
const emoji = getEmojiParentByKey(parentKey);
|
||||
localizedKeys.add(parentKey);
|
||||
results.push({
|
||||
key: parentKey,
|
||||
rank: localeEmoji.rank,
|
||||
|
@ -66,6 +70,12 @@ export function createFunEmojiSearchIndex(
|
|||
});
|
||||
}
|
||||
|
||||
for (const defaultEntry of defaultSearchIndex) {
|
||||
if (!localizedKeys.has(defaultEntry.key)) {
|
||||
results.push(defaultEntry);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue