Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Allow emoticon to be an array
Browse files Browse the repository at this point in the history
Signed-off-by: Šimon Brandner <[email protected]>
  • Loading branch information
SimonBrandner committed Dec 5, 2021
1 parent 2e4feaf commit 7d1966e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/views/emojipicker/EmojiPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ class EmojiPicker extends React.Component<IProps, IState> {

private emojiMatchesFilter = (emoji: IEmoji, filter: string): boolean => {
return emoji.label.toLowerCase().includes(filter) ||
emoji.emoticon?.toLowerCase().includes(filter) ||
(Array.isArray(emoji.emoticon)
? emoji.emoticon.some((x) => x.includes(filter))
: emoji.emoticon.includes(filter)
) ||
emoji.shortcodes.some(x => x.toLowerCase().includes(filter)) ||
emoji.unicode.split(ZERO_WIDTH_JOINER).includes(filter);
};
Expand Down
6 changes: 4 additions & 2 deletions src/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface IEmoji {
tags?: string[];
unicode: string;
skins?: Omit<IEmoji, "shortcodes" | "tags">[]; // Currently unused
emoticon?: string;
emoticon?: string | string[];
}

// The unicode is stored without the variant selector
Expand Down Expand Up @@ -102,7 +102,9 @@ export const EMOJI: IEmoji[] = EMOJIBASE.map((emojiData: Omit<IEmoji, "shortcode

if (emoji.emoticon) {
// Add mapping from emoticon to Emoji object
EMOTICON_TO_EMOJI.set(emoji.emoticon, emoji);
Array.isArray(emoji.emoticon)
? emoji.emoticon.forEach((x) => EMOTICON_TO_EMOJI.set(x, emoji))
: EMOTICON_TO_EMOJI.set(emoji.emoticon, emoji);
}

return emoji;
Expand Down

0 comments on commit 7d1966e

Please sign in to comment.