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

fix: emoji showing original message for few moments #21933

Merged
merged 7 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions src/libs/ReportActionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,20 @@ function getLinkedTransactionID(reportID, reportActionID) {
return reportAction.originalMessage.IOUTransactionID;
}

/**
* Returns the parentReportAction if the given report is a thread/task.
jeet-dhandha marked this conversation as resolved.
Show resolved Hide resolved
*
* @param {String} reportID
* @param {String} reportActionID
* @returns {Object}
*/
function getReportAction(reportID, reportActionID) {
jeet-dhandha marked this conversation as resolved.
Show resolved Hide resolved
if (!reportID || !reportActionID) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function can be simplified. lodashget already takes care of it for us, no?

we can remove this if block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Will update that.

return {};
}
return lodashGet(allReportActions, [reportID, reportActionID], {});
}

/**
* @param {*} chatReportID
* @param {*} iouReportID
Expand Down Expand Up @@ -492,4 +506,5 @@ export {
isMessageDeleted,
isWhisperAction,
isPendingRemove,
getReportAction,
};
7 changes: 4 additions & 3 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1639,15 +1639,16 @@ function removeEmojiReaction(reportID, originalReportAction, emoji) {
* @returns {Promise}
*/
function toggleEmojiReaction(reportID, reportAction, emoji, paramSkinTone = preferredSkinTone) {
const message = reportAction.message[0];
const latestReportAction = ReportActionsUtils.getReportAction(reportID, reportAction.reportActionID);
jeet-dhandha marked this conversation as resolved.
Show resolved Hide resolved
const message = latestReportAction.message[0];
jeet-dhandha marked this conversation as resolved.
Show resolved Hide resolved
const reactionObject = message.reactions && _.find(message.reactions, (reaction) => reaction.emoji === emoji.name);
const skinTone = emoji.types === undefined ? null : paramSkinTone; // only use skin tone if emoji supports it
if (reactionObject) {
if (hasAccountIDReacted(currentUserAccountID, reactionObject.users, skinTone)) {
return removeEmojiReaction(reportID, reportAction, emoji, skinTone);
return removeEmojiReaction(reportID, latestReportAction, emoji, skinTone);
}
}
return addEmojiReaction(reportID, reportAction, emoji, skinTone);
return addEmojiReaction(reportID, latestReportAction, emoji, skinTone);
}

/**
Expand Down