Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the emoji reaction when pressing on the added reaction #47038

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2549,6 +2549,7 @@ function toggleEmojiReaction(
reactionObject: Emoji,
existingReactions: OnyxEntry<ReportActionReactions>,
paramSkinTone: number = preferredSkinTone,
ignoreSkinToneOnCompare = false,
) {
const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction);

Expand All @@ -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;
}
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 @@ -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],
);
Expand Down Expand Up @@ -749,15 +749,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
Loading