From fd300e2d59ce8f62f95dfb4caa233cc1f43faba5 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Wed, 21 Jun 2023 14:50:35 +0530 Subject: [PATCH 1/6] fix: Changes --- src/components/MoneyRequestConfirmationList.js | 4 ++-- src/languages/en.js | 4 ++-- src/languages/es.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 05d56f390b2a..01a9dbda4cd9 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -162,13 +162,13 @@ function MoneyRequestConfirmationList(props) { sections.push( { - title: translate('moneyRequestConfirmationList.whoPaid'), + title: translate('moneyRequestConfirmationList.paidBy'), data: [formattedPayeeOption], shouldShow: true, indexOffset: 0, }, { - title: translate('moneyRequestConfirmationList.whoWasThere'), + title: translate('moneyRequestConfirmationList.splitWith'), data: formattedParticipantsList, shouldShow: true, indexOffset: 1, diff --git a/src/languages/en.js b/src/languages/en.js index 192d9954e5ff..37ec0cc42779 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -202,8 +202,8 @@ export default { tfaRequiredDescription: 'Please enter the two-factor authentication code\nwhere you are trying to sign in.', }, moneyRequestConfirmationList: { - whoPaid: 'Who paid?', - whoWasThere: 'Who was there?', + paidBy: 'Paid by', + splitWith: 'Split with', whatsItFor: "What's it for?", }, iOUCurrencySelection: { diff --git a/src/languages/es.js b/src/languages/es.js index d54fa5110117..86efd180a72c 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -201,8 +201,8 @@ export default { tfaRequiredDescription: 'Por favor, introduce el código de autenticación de dos factores\ndonde estás intentando iniciar sesión.', }, moneyRequestConfirmationList: { - whoPaid: '¿Quién pago?', - whoWasThere: '¿Quién asistió?', + paidBy: 'Pagado por', + splitWith: 'Dividir con', whatsItFor: '¿Para qué es?', }, iOUCurrencySelection: { From 06f9bbcc33d4fe734f9566ce4fe06f6fa89e505a Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Wed, 21 Jun 2023 14:51:24 +0530 Subject: [PATCH 2/6] Revert "fix: Changes" This reverts commit fd300e2d59ce8f62f95dfb4caa233cc1f43faba5. --- src/components/MoneyRequestConfirmationList.js | 4 ++-- src/languages/en.js | 4 ++-- src/languages/es.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 01a9dbda4cd9..05d56f390b2a 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -162,13 +162,13 @@ function MoneyRequestConfirmationList(props) { sections.push( { - title: translate('moneyRequestConfirmationList.paidBy'), + title: translate('moneyRequestConfirmationList.whoPaid'), data: [formattedPayeeOption], shouldShow: true, indexOffset: 0, }, { - title: translate('moneyRequestConfirmationList.splitWith'), + title: translate('moneyRequestConfirmationList.whoWasThere'), data: formattedParticipantsList, shouldShow: true, indexOffset: 1, diff --git a/src/languages/en.js b/src/languages/en.js index 37ec0cc42779..192d9954e5ff 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -202,8 +202,8 @@ export default { tfaRequiredDescription: 'Please enter the two-factor authentication code\nwhere you are trying to sign in.', }, moneyRequestConfirmationList: { - paidBy: 'Paid by', - splitWith: 'Split with', + whoPaid: 'Who paid?', + whoWasThere: 'Who was there?', whatsItFor: "What's it for?", }, iOUCurrencySelection: { diff --git a/src/languages/es.js b/src/languages/es.js index 86efd180a72c..d54fa5110117 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -201,8 +201,8 @@ export default { tfaRequiredDescription: 'Por favor, introduce el código de autenticación de dos factores\ndonde estás intentando iniciar sesión.', }, moneyRequestConfirmationList: { - paidBy: 'Pagado por', - splitWith: 'Dividir con', + whoPaid: '¿Quién pago?', + whoWasThere: '¿Quién asistió?', whatsItFor: '¿Para qué es?', }, iOUCurrencySelection: { From d126def573643abdf8a9b1dbcd2fd283d9d2e0c7 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Wed, 5 Jul 2023 19:49:59 +0530 Subject: [PATCH 3/6] fix-regression --- src/libs/actions/Report.js | 7 ++++--- src/pages/home/report/ContextMenu/ContextMenuActions.js | 2 +- src/pages/home/report/ReportActionItem.js | 2 +- tests/actions/ReportTest.js | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 9027b8fb2f3c..f755cccb3892 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1635,13 +1635,14 @@ 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 {String} reportActionID + * @param {Object} action * @param {Object} emoji * @param {number} paramSkinTone * @returns {Promise} */ -function toggleEmojiReaction(reportID, reportActionID, emoji, paramSkinTone = preferredSkinTone) { - const reportAction = ReportActionsUtils.getReportAction(reportID, reportActionID); +function toggleEmojiReaction(reportID, action, emoji, paramSkinTone = preferredSkinTone) { + const originalReportID = ReportUtils.getOriginalReportID(reportID, action); + const reportAction = ReportActionsUtils.getReportAction(originalReportID, action.reportActionID); if (_.isEmpty(reportAction)) { return; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 4b7ddaec1f99..7f36eb9ac8b3 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -58,7 +58,7 @@ export default [ }; const onEmojiSelected = (emoji) => { - Report.toggleEmojiReaction(reportID, reportAction.reportActionID, emoji); + Report.toggleEmojiReaction(reportID, reportAction, emoji); closeContextMenu(); }; diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 2afd28f934fe..dad7d1f41b48 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -199,7 +199,7 @@ function ReportActionItem(props) { const toggleReaction = useCallback( (emoji) => { - Report.toggleEmojiReaction(props.report.reportID, props.action.reportActionID, emoji); + Report.toggleEmojiReaction(props.report.reportID, props.action, emoji); }, [props.report, props.action], ); diff --git a/tests/actions/ReportTest.js b/tests/actions/ReportTest.js index 5566c66df4b7..6fbf3b88dd82 100644 --- a/tests/actions/ReportTest.js +++ b/tests/actions/ReportTest.js @@ -656,7 +656,7 @@ describe('actions/Report', () => { const resultAction = _.first(_.values(reportActions)); // Add a reaction to the comment - Report.toggleEmojiReaction(REPORT_ID, resultAction.reportActionID, EMOJI); + Report.toggleEmojiReaction(REPORT_ID, resultAction, EMOJI); return waitForPromisesToResolve(); }) .then(() => { @@ -665,7 +665,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.reportActionID, EMOJI, 2); + Report.toggleEmojiReaction(REPORT_ID, resultAction, EMOJI, 2); return waitForPromisesToResolve(); }) .then(() => { From ae0706333ea3682c00fb03ae1d37e25663a8e150 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Wed, 5 Jul 2023 21:24:52 +0530 Subject: [PATCH 4/6] fix: report action name changes --- src/libs/actions/Report.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index f755cccb3892..32bfbb376bd0 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1531,13 +1531,12 @@ function hasAccountIDReacted(accountID, users, skinTone) { /** * Adds a reaction to the report action. - * @param {String} reportID + * @param {String} originalReportID * @param {Object} originalReportAction * @param {{ name: string, code: string, types: string[] }} emoji * @param {number} [skinTone] Optional. */ -function addEmojiReaction(reportID, originalReportAction, emoji, skinTone = preferredSkinTone) { - const originalReportID = ReportUtils.getOriginalReportID(reportID, originalReportAction); +function addEmojiReaction(originalReportID, originalReportAction, emoji, skinTone = preferredSkinTone) { const message = originalReportAction.message[0]; let reactionObject = message.reactions && _.find(message.reactions, (reaction) => reaction.emoji === emoji.name); const needToInsertReactionObject = !reactionObject; @@ -1583,12 +1582,11 @@ function addEmojiReaction(reportID, originalReportAction, emoji, skinTone = pref /** * Removes a reaction to the report action. - * @param {String} reportID + * @param {String} originalReportID * @param {Object} originalReportAction * @param {{ name: string, code: string, types: string[] }} emoji */ -function removeEmojiReaction(reportID, originalReportAction, emoji) { - const originalReportID = ReportUtils.getOriginalReportID(reportID, originalReportAction); +function removeEmojiReaction(originalReportID, originalReportAction, emoji) { const message = originalReportAction.message[0]; const reactionObject = message.reactions && _.find(message.reactions, (reaction) => reaction.emoji === emoji.name); if (!reactionObject) { @@ -1635,28 +1633,28 @@ 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} action + * @param {Object} reportAction * @param {Object} emoji * @param {number} paramSkinTone * @returns {Promise} */ -function toggleEmojiReaction(reportID, action, emoji, paramSkinTone = preferredSkinTone) { - const originalReportID = ReportUtils.getOriginalReportID(reportID, action); - const reportAction = ReportActionsUtils.getReportAction(originalReportID, action.reportActionID); +function toggleEmojiReaction(reportID, reportAction, emoji, paramSkinTone = preferredSkinTone) { + const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction); + const originalReportAction = ReportActionsUtils.getReportAction(originalReportID, reportAction.reportActionID); - if (_.isEmpty(reportAction)) { + if (_.isEmpty(originalReportAction)) { return; } - const message = reportAction.message[0]; + const message = originalReportAction.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 if (reactionObject) { if (hasAccountIDReacted(currentUserAccountID, reactionObject.users, skinTone)) { - return removeEmojiReaction(reportID, reportAction, emoji, skinTone); + return removeEmojiReaction(originalReportID, originalReportAction, emoji, skinTone); } } - return addEmojiReaction(reportID, reportAction, emoji, skinTone); + return addEmojiReaction(originalReportID, originalReportAction, emoji, skinTone); } /** From db668d35187b7c911f6a20d5a4916e7099a2acbc Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Thu, 20 Jul 2023 18:20:36 +0530 Subject: [PATCH 5/6] chore: use reportId from reportAction --- src/libs/actions/Report.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 6fb0351b3133..a901837407fa 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1667,11 +1667,11 @@ function toggleEmojiReaction(reportID, reportAction, reactionObject, existingRea const skinTone = emoji.types === undefined ? -1 : paramSkinTone; if (existingReactionObject && hasAccountIDEmojiReacted(currentUserAccountID, existingReactionObject.users, skinTone)) { - removeEmojiReaction(reportID, originalReportAction.reportActionID, emoji); + removeEmojiReaction(reportID, reportAction.reportActionID, emoji); return; } - addEmojiReaction(reportID, originalReportAction.reportActionID, emoji, skinTone); + addEmojiReaction(reportID, reportAction.reportActionID, emoji, skinTone); } /** From 229a5d3692967e69881bc277e29ab5e98a22abb2 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Fri, 21 Jul 2023 00:38:12 +0530 Subject: [PATCH 6/6] chore: change jsdoc type --- src/libs/actions/Report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index a901837407fa..855c0f2a098d 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1645,7 +1645,7 @@ function removeEmojiReaction(reportID, reportActionID, emoji) { * Calls either addEmojiReaction or removeEmojiReaction depending on if the current user has reacted to the report action. * Uses the NEW FORMAT for "emojiReactions" * @param {String} reportID - * @param {String} reportAction + * @param {Object} reportAction * @param {Object} reactionObject * @param {Object} existingReactions * @param {Number} [paramSkinTone]