diff --git a/ts/components/fun/data/emojis.ts b/ts/components/fun/data/emojis.ts index 0e7acb769b..98805fb4e2 100644 --- a/ts/components/fun/data/emojis.ts +++ b/ts/components/fun/data/emojis.ts @@ -228,6 +228,56 @@ function toEmojiVariantValue(unified: string): EmojiVariantValue { return encodeUnified(unified) as EmojiVariantValue; } +const WOMAN = '\u{1F469}'; +const MAN = '\u{1F468}'; +const GIRL = '\u{1F467}'; +const BOY = '\u{1F466}'; +const ZWJ = '\u{200D}'; + +/** + * Deprecated unicode emoji should continue to be rendered when used, + * but should be hidden from emoji pickers. + */ +const UNICODE_DEPRECATED_EMOJI = new Set([ + /** + * 2022 - Family Emoji Redesign: Gender Inclusive Variants + * https://www.unicode.org/L2/L2023/23029-family-emoji.pdf + * https://www.unicode.org/L2/L2022/22276-family-emoji-guidelines.pdf + */ + + // 1 ADULT, 1 CHILD + `${WOMAN}${ZWJ}${GIRL}`, + `${WOMAN}${ZWJ}${BOY}`, + `${MAN}${ZWJ}${GIRL}`, + `${MAN}${ZWJ}${BOY}`, + // 1 ADULT, 2 CHILDREN + `${WOMAN}${ZWJ}${GIRL}${ZWJ}${GIRL}`, + `${WOMAN}${ZWJ}${GIRL}${ZWJ}${BOY}`, + `${WOMAN}${ZWJ}${BOY}${ZWJ}${BOY}`, + `${MAN}${ZWJ}${GIRL}${ZWJ}${GIRL}`, + `${MAN}${ZWJ}${GIRL}${ZWJ}${BOY}`, + `${MAN}${ZWJ}${BOY}${ZWJ}${BOY}`, + // 2 ADULTS, 1 CHILD + `${WOMAN}${ZWJ}${WOMAN}${ZWJ}${GIRL}`, + `${WOMAN}${ZWJ}${WOMAN}${ZWJ}${BOY}`, + `${MAN}${ZWJ}${WOMAN}${ZWJ}${GIRL}`, + `${MAN}${ZWJ}${WOMAN}${ZWJ}${BOY}`, + `${MAN}${ZWJ}${MAN}${ZWJ}${GIRL}`, + `${MAN}${ZWJ}${MAN}${ZWJ}${BOY}`, + // 2 ADULTS, 2 CHILDREN + `${WOMAN}${ZWJ}${WOMAN}${ZWJ}${GIRL}${ZWJ}${GIRL}`, + `${WOMAN}${ZWJ}${WOMAN}${ZWJ}${GIRL}${ZWJ}${BOY}`, + `${WOMAN}${ZWJ}${WOMAN}${ZWJ}${BOY}${ZWJ}${BOY}`, + + `${MAN}${ZWJ}${WOMAN}${ZWJ}${GIRL}${ZWJ}${GIRL}`, + `${MAN}${ZWJ}${WOMAN}${ZWJ}${GIRL}${ZWJ}${BOY}`, + `${MAN}${ZWJ}${WOMAN}${ZWJ}${BOY}${ZWJ}${BOY}`, + + `${MAN}${ZWJ}${MAN}${ZWJ}${GIRL}${ZWJ}${GIRL}`, + `${MAN}${ZWJ}${MAN}${ZWJ}${GIRL}${ZWJ}${BOY}`, + `${MAN}${ZWJ}${MAN}${ZWJ}${BOY}${ZWJ}${BOY}`, +] as Array); + const RAW_EMOJI_DATA = parseUnknown( z.array(RawEmojiSchema), RAW_UNTYPED_DATA @@ -300,6 +350,8 @@ const EMOJI_INDEX: EmojiIndex = { }; function addParent(parent: EmojiParentData, rank: number) { + const isDeprecated = UNICODE_DEPRECATED_EMOJI.has(parent.value); + EMOJI_INDEX.parentByKey.set(parent.key, parent); EMOJI_INDEX.parentKeysByValue.set(parent.value, parent.key); if (parent.valueNonqualified != null) { @@ -311,7 +363,7 @@ function addParent(parent: EmojiParentData, rank: number) { } EMOJI_INDEX.parentKeysByName.set(parent.englishShortNameDefault, parent.key); EMOJI_INDEX.unicodeCategories[parent.unicodeCategory].push(parent.key); - if (parent.pickerCategory != null) { + if (parent.pickerCategory != null && !isDeprecated) { EMOJI_INDEX.pickerCategories[parent.pickerCategory].push(parent.key); } @@ -319,14 +371,16 @@ function addParent(parent: EmojiParentData, rank: number) { EMOJI_INDEX.parentKeysByName.set(englishShortName, parent.key); } - EMOJI_INDEX.defaultEnglishSearchIndex.push({ - key: parent.key, - rank, - shortName: parent.englishShortNameDefault, - shortNames: parent.englishShortNames, - emoticon: parent.emoticonDefault, - emoticons: parent.emoticons, - }); + if (!isDeprecated) { + EMOJI_INDEX.defaultEnglishSearchIndex.push({ + key: parent.key, + rank, + shortName: parent.englishShortNameDefault, + shortNames: parent.englishShortNames, + emoticon: parent.emoticonDefault, + emoticons: parent.emoticons, + }); + } EMOJI_INDEX.defaultEnglishLocalizerIndex.parentKeyToLocaleShortName.set( parent.key, @@ -429,6 +483,10 @@ export function isEmojiParentKey(input: string): input is EmojiParentKey { return EMOJI_INDEX.parentByKey.has(input as EmojiParentKey); } +export function isEmojiParentValueDeprecated(input: EmojiParentValue): boolean { + return UNICODE_DEPRECATED_EMOJI.has(input); +} + export function isEmojiVariantKey(input: string): input is EmojiVariantKey { return EMOJI_INDEX.variantByKey.has(input as EmojiVariantKey); } diff --git a/ts/components/fun/useFunEmojiSearch.tsx b/ts/components/fun/useFunEmojiSearch.tsx index 1726851128..d8102d2d8c 100644 --- a/ts/components/fun/useFunEmojiSearch.tsx +++ b/ts/components/fun/useFunEmojiSearch.tsx @@ -8,6 +8,7 @@ import { getEmojiParentByKey, getEmojiParentKeyByValue, isEmojiParentValue, + isEmojiParentValueDeprecated, normalizeShortNameCompletionQuery, } from './data/emojis'; import type { LocaleEmojiListType } from '../../types/emoji'; @@ -44,6 +45,11 @@ export function createFunEmojiSearchIndex( continue; } + if (isEmojiParentValueDeprecated(localeEmoji.emoji)) { + // Skipping deprecated emoji + continue; + } + const parentKey = getEmojiParentKeyByValue(localeEmoji.emoji); const emoji = getEmojiParentByKey(parentKey); results.push({