From 3ac4099d71fa1b0b2d59a922f5400d36c3d77416 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 8 Aug 2024 15:55:07 +0800 Subject: [PATCH] remove the reaction when pressing on the added reaction --- .../Reactions/ReportActionItemEmojiReactions.tsx | 4 ++-- src/libs/actions/Report.ts | 3 ++- src/pages/home/report/ReportActionItem.tsx | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/Reactions/ReportActionItemEmojiReactions.tsx b/src/components/Reactions/ReportActionItemEmojiReactions.tsx index c6bf4f9e4016..943158607db4 100644 --- a/src/components/Reactions/ReportActionItemEmojiReactions.tsx +++ b/src/components/Reactions/ReportActionItemEmojiReactions.tsx @@ -33,7 +33,7 @@ type ReportActionItemEmojiReactionsProps = WithCurrentUserPersonalDetailsProps & * This can also be an emoji the user already reacted with, * hence this function asks to toggle the reaction by emoji. */ - toggleReaction: (emoji: Emoji) => void; + toggleReaction: (emoji: Emoji, ignoreSkinToneOnCompare?: boolean) => void; /** We disable reacting with emojis on report actions that have errors */ shouldBlockReactions?: boolean; @@ -107,7 +107,7 @@ function ReportActionItemEmojiReactions({ totalReactionCount += reactionCount; const onPress = () => { - toggleReaction(emoji); + toggleReaction(emoji, true); }; const onReactionListOpen = (event: ReactionListEvent) => { diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index ca489b923265..dc0d44535c8a 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2549,6 +2549,7 @@ function toggleEmojiReaction( reactionObject: Emoji, existingReactions: OnyxEntry, paramSkinTone: number = preferredSkinTone, + ignoreSkinToneOnCompare = false, ) { const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction); @@ -2570,7 +2571,7 @@ function toggleEmojiReaction( // Only use skin tone if emoji supports it const skinTone = emoji.types === undefined ? -1 : paramSkinTone; - if (existingReactionObject && EmojiUtils.hasAccountIDEmojiReacted(currentUserAccountID, existingReactionObject.users, skinTone)) { + if (existingReactionObject && EmojiUtils.hasAccountIDEmojiReacted(currentUserAccountID, existingReactionObject.users, ignoreSkinToneOnCompare ? undefined : skinTone)) { removeEmojiReaction(originalReportID, reportAction.reportActionID, emoji); return; } diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 68ced63d12d0..0799e257d428 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -380,8 +380,8 @@ function ReportActionItem({ }, [index, originalMessage, prevActionResolution, reportScrollManager, isActionableWhisper]); const toggleReaction = useCallback( - (emoji: Emoji) => { - Report.toggleEmojiReaction(report.reportID, action, emoji, emojiReactions); + (emoji: Emoji, ignoreSkinToneOnCompare?: boolean) => { + Report.toggleEmojiReaction(report.reportID, action, emoji, emojiReactions, undefined, ignoreSkinToneOnCompare); }, [report, action, emojiReactions], ); @@ -749,7 +749,7 @@ function ReportActionItem({ reportAction={action} emojiReactions={emojiReactions} shouldBlockReactions={hasErrors} - toggleReaction={(emoji) => { + toggleReaction={(emoji, ignoreSkinToneOnCompare) => { if (Session.isAnonymousUser()) { hideContextMenu(false); @@ -757,7 +757,7 @@ function ReportActionItem({ Session.signOutAndRedirectToSignIn(); }); } else { - toggleReaction(emoji); + toggleReaction(emoji, ignoreSkinToneOnCompare); } }} setIsEmojiPickerActive={setIsEmojiPickerActive}