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 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
11 changes: 11 additions & 0 deletions src/libs/ReportActionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,16 @@ function getLinkedTransactionID(reportID, reportActionID) {
return reportAction.originalMessage.IOUTransactionID;
}

/**
*
* @param {String} reportID
* @param {String} reportActionID
* @returns {Object}
*/
function getReportAction(reportID, reportActionID) {
jeet-dhandha marked this conversation as resolved.
Show resolved Hide resolved
return lodashGet(allReportActions, [reportID, reportActionID], {});
}

/**
* @param {*} chatReportID
* @param {*} iouReportID
Expand Down Expand Up @@ -492,4 +502,5 @@ export {
isMessageDeleted,
isWhisperAction,
isPendingRemove,
getReportAction,
};
10 changes: 8 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1633,12 +1633,18 @@ function removeEmojiReaction(reportID, originalReportAction, emoji) {
/**
* Calls either addEmojiReaction or removeEmojiReaction depending on if the current user has reacted to the report action.
* @param {String} reportID
* @param {Object} reportAction
* @param {String} reportActionID
* @param {Object} emoji
* @param {number} paramSkinTone
* @returns {Promise}
*/
function toggleEmojiReaction(reportID, reportAction, emoji, paramSkinTone = preferredSkinTone) {
function toggleEmojiReaction(reportID, reportActionID, emoji, paramSkinTone = preferredSkinTone) {
Copy link
Contributor

@dukenv0307 dukenv0307 Jul 5, 2023

Choose a reason for hiding this comment

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

@rushatgabhane Seems like the PR makes a regression #22235

const reportAction = ReportActionsUtils.getReportAction(reportID, reportActionID);

if (_.isEmpty(reportAction)) {
return;
}

const message = reportAction.message[0];
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
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default [
};

const onEmojiSelected = (emoji) => {
Report.toggleEmojiReaction(reportID, reportAction, emoji);
Report.toggleEmojiReaction(reportID, reportAction.reportActionID, emoji);
closeContextMenu();
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function ReportActionItem(props) {

const toggleReaction = useCallback(
(emoji) => {
Report.toggleEmojiReaction(props.report.reportID, props.action, emoji);
Report.toggleEmojiReaction(props.report.reportID, props.action.reportActionID, emoji);
},
[props.report, props.action],
);
Expand Down
4 changes: 2 additions & 2 deletions tests/actions/ReportTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ describe('actions/Report', () => {
const resultAction = _.first(_.values(reportActions));

// Add a reaction to the comment
Report.toggleEmojiReaction(REPORT_ID, resultAction, EMOJI);
Report.toggleEmojiReaction(REPORT_ID, resultAction.reportActionID, EMOJI);
return waitForPromisesToResolve();
})
.then(() => {
Expand All @@ -668,7 +668,7 @@ describe('actions/Report', () => {
// Now we toggle the reaction while the skin tone has changed.
// As the emoji doesn't support skin tones, the emoji
// should get removed instead of added again.
Report.toggleEmojiReaction(REPORT_ID, resultAction, EMOJI, 2);
Report.toggleEmojiReaction(REPORT_ID, resultAction.reportActionID, EMOJI, 2);
return waitForPromisesToResolve();
})
.then(() => {
Expand Down