Skip to content

Commit

Permalink
Merge pull request #47038 from bernhardoj/fix/46387-emoji-reaction-no…
Browse files Browse the repository at this point in the history
…t-removed

Remove the emoji reaction when pressing on the added reaction
  • Loading branch information
chiragsalian authored Aug 27, 2024
2 parents 77ed3e1 + 3ac4099 commit bae2977
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/Reactions/ReportActionItemEmojiReactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -107,7 +107,7 @@ function ReportActionItemEmojiReactions({
totalReactionCount += reactionCount;

const onPress = () => {
toggleReaction(emoji);
toggleReaction(emoji, true);
};

const onReactionListOpen = (event: ReactionListEvent) => {
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,7 @@ function toggleEmojiReaction(
reactionObject: Emoji,
existingReactions: OnyxEntry<ReportActionReactions>,
paramSkinTone: number = preferredSkinTone,
ignoreSkinToneOnCompare = false,
) {
const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction);

Expand All @@ -2633,7 +2634,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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ function ReportActionItem({
}, [index, originalMessage, prevActionResolution, reportScrollManager, isActionableWhisper, hasResolutionInOriginalMessage]);

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],
);
Expand Down Expand Up @@ -757,15 +757,15 @@ function ReportActionItem({
reportAction={action}
emojiReactions={emojiReactions}
shouldBlockReactions={hasErrors}
toggleReaction={(emoji) => {
toggleReaction={(emoji, ignoreSkinToneOnCompare) => {
if (Session.isAnonymousUser()) {
hideContextMenu(false);

InteractionManager.runAfterInteractions(() => {
Session.signOutAndRedirectToSignIn();
});
} else {
toggleReaction(emoji);
toggleReaction(emoji, ignoreSkinToneOnCompare);
}
}}
setIsEmojiPickerActive={setIsEmojiPickerActive}
Expand Down

0 comments on commit bae2977

Please sign in to comment.