From aefdac1115db9e13019209e2c8c9be6f62dec657 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Tue, 20 Jul 2021 22:41:49 -0400 Subject: [PATCH 1/2] Fix error when hovering over non-emoji reactions Signed-off-by: Robin Townsend --- src/HtmlUtils.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HtmlUtils.tsx b/src/HtmlUtils.tsx index 3c34bf6837..00734f69f8 100644 --- a/src/HtmlUtils.tsx +++ b/src/HtmlUtils.tsx @@ -79,8 +79,8 @@ function mightContainEmoji(str: string): boolean { * @return {String} The shortcode (such as :thumbup:) */ export function unicodeToShortcode(char: string): string { - const shortcodes = getEmojiFromUnicode(char).shortcodes; - return shortcodes.length > 0 ? `:${shortcodes[0]}:` : ''; + const shortcodes = getEmojiFromUnicode(char)?.shortcodes; + return shortcodes && shortcodes.length > 0 ? `:${shortcodes[0]}:` : ''; } export function processHtmlForSending(html: string): string { From 1d1d93ed147f8dbaa665a3ac31d8cf4f19c79bfe Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Wed, 21 Jul 2021 03:17:55 -0400 Subject: [PATCH 2/2] Apply code review suggestion Signed-off-by: Robin Townsend --- src/HtmlUtils.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HtmlUtils.tsx b/src/HtmlUtils.tsx index 00734f69f8..b125ddeeb5 100644 --- a/src/HtmlUtils.tsx +++ b/src/HtmlUtils.tsx @@ -80,7 +80,7 @@ function mightContainEmoji(str: string): boolean { */ export function unicodeToShortcode(char: string): string { const shortcodes = getEmojiFromUnicode(char)?.shortcodes; - return shortcodes && shortcodes.length > 0 ? `:${shortcodes[0]}:` : ''; + return shortcodes?.length ? `:${shortcodes[0]}:` : ''; } export function processHtmlForSending(html: string): string {