From d0b45ec023085952b7c7ae131c0378827b63c1f1 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 12 Sep 2023 14:30:53 -0400 Subject: [PATCH 01/15] allow other types of notifications --- src/libs/actions/Report.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 85552fa14a56..8c8c48a20153 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1566,12 +1566,6 @@ function shouldShowReportActionNotification(reportID, action = null, isRemote = return false; } - // Don't show a notification if no comment exists - if (action && !_.some(action.message, (f) => f.type === 'COMMENT')) { - Log.info(`${tag} No notification because no comments exist for the current action`); - return false; - } - return true; } From 93a5891659703faeb8a88b5a506d2257e8058930 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 12 Sep 2023 14:43:32 -0400 Subject: [PATCH 02/15] rename action to reportAction --- src/libs/actions/Report.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 8c8c48a20153..fed4efd2e3d2 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1571,23 +1571,23 @@ function shouldShowReportActionNotification(reportID, action = null, isRemote = /** * @param {String} reportID - * @param {Object} action + * @param {Object} reportAction */ -function showReportActionNotification(reportID, action) { - if (!shouldShowReportActionNotification(reportID, action)) { +function showReportActionNotification(reportID, reportAction) { + if (!shouldShowReportActionNotification(reportID, reportAction)) { return; } Log.info('[LocalNotification] Creating notification'); LocalNotification.showCommentNotification({ report: allReports[reportID], - reportAction: action, + reportAction, onClick: () => { // Navigate to this report onClick Navigation.navigate(ROUTES.getReportRoute(reportID)); }, }); - notifyNewAction(reportID, action.actorAccountID, action.reportActionID); + notifyNewAction(reportID, reportAction.actorAccountID, reportAction.reportActionID); } /** From cabe7a55afc8eb71f284d104145e13fdbe7c89b0 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 12 Sep 2023 15:41:39 -0400 Subject: [PATCH 03/15] use formatting for modified expense notifications --- .../LocalNotification/BrowserNotifications.js | 9 +++++++ .../LocalNotification/index.desktop.js | 5 ++++ .../LocalNotification/index.native.js | 1 + .../LocalNotification/index.website.js | 5 ++++ src/libs/actions/Report.js | 24 ++++++++++++------- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.js b/src/libs/Notification/LocalNotification/BrowserNotifications.js index e55c0430fe17..11c857abc972 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.js +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.js @@ -128,6 +128,15 @@ export default { }); }, + pushModifiedExpenseNotification({report, reportAction, onClick}) { + push({ + title: report.reportName, + body: ReportUtils.getModifiedExpenseMessage(reportAction), + delay: 0, + onClick, + }); + }, + /** * Create a notification to indicate that an update is available. */ diff --git a/src/libs/Notification/LocalNotification/index.desktop.js b/src/libs/Notification/LocalNotification/index.desktop.js index 2bef51cea0a6..6e526da2bd1f 100644 --- a/src/libs/Notification/LocalNotification/index.desktop.js +++ b/src/libs/Notification/LocalNotification/index.desktop.js @@ -8,7 +8,12 @@ function showUpdateAvailableNotification() { BrowserNotifications.pushUpdateAvailableNotification(); } +function showModifiedExpenseNotification({report, reportAction, onClick}) { + BrowserNotifications.pushModifiedExpenseNotification({report, reportAction, onClick}); +} + export default { showCommentNotification, showUpdateAvailableNotification, + showModifiedExpenseNotification, }; diff --git a/src/libs/Notification/LocalNotification/index.native.js b/src/libs/Notification/LocalNotification/index.native.js index bbc4f48744b6..1f1771e619a5 100644 --- a/src/libs/Notification/LocalNotification/index.native.js +++ b/src/libs/Notification/LocalNotification/index.native.js @@ -2,4 +2,5 @@ export default { showCommentNotification: () => {}, showUpdateAvailableNotification: () => {}, + showModifiedExpenseNotification: () => {}, }; diff --git a/src/libs/Notification/LocalNotification/index.website.js b/src/libs/Notification/LocalNotification/index.website.js index 3410b3144caf..ef5ee101b16d 100644 --- a/src/libs/Notification/LocalNotification/index.website.js +++ b/src/libs/Notification/LocalNotification/index.website.js @@ -8,7 +8,12 @@ function showUpdateAvailableNotification() { BrowserNotifications.pushUpdateAvailableNotification(); } +function showModifiedExpenseNotification({report, reportAction, onClick}) { + BrowserNotifications.pushModifiedExpenseNotification({report, reportAction, onClick}); +} + export default { showCommentNotification, showUpdateAvailableNotification, + showModifiedExpenseNotification, }; diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index fed4efd2e3d2..4479b0982f23 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1579,14 +1579,22 @@ function showReportActionNotification(reportID, reportAction) { } Log.info('[LocalNotification] Creating notification'); - LocalNotification.showCommentNotification({ - report: allReports[reportID], - reportAction, - onClick: () => { - // Navigate to this report onClick - Navigation.navigate(ROUTES.getReportRoute(reportID)); - }, - }); + const report = allReports[reportID]; + + if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) { + LocalNotification.showModifiedExpenseNotification({ + report, + reportAction, + onClick: () => Navigation.navigate(ROUTES.getReportRoute(reportID)), + }); + } else { + LocalNotification.showCommentNotification({ + report, + reportAction, + onClick: () => Navigation.navigate(ROUTES.getReportRoute(reportID)), + }); + } + notifyNewAction(reportID, reportAction.actorAccountID, reportAction.reportActionID); } From ada24327e5eb114e46177363ecc1815999550386 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 12 Sep 2023 18:35:42 -0400 Subject: [PATCH 04/15] only allow some types of actions for notifications --- src/libs/actions/Report.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 4479b0982f23..2965594488ca 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1566,6 +1566,11 @@ function shouldShowReportActionNotification(reportID, action = null, isRemote = return false; } + // Only show notifications for supported types of report actions + if (action && !_.contains([CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE], action.actionName)) { + return false; + } + return true; } From d74bc4e2f0a00898b858f5dec6880b36824a782d Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 12 Sep 2023 18:49:55 -0400 Subject: [PATCH 05/15] use report action user as title --- .../Notification/LocalNotification/BrowserNotifications.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.js b/src/libs/Notification/LocalNotification/BrowserNotifications.js index 11c857abc972..99e274d42d1f 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.js +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.js @@ -128,9 +128,9 @@ export default { }); }, - pushModifiedExpenseNotification({report, reportAction, onClick}) { + pushModifiedExpenseNotification({reportAction, onClick}) { push({ - title: report.reportName, + title: _.map(reportAction.person, (f) => f.text).join(), body: ReportUtils.getModifiedExpenseMessage(reportAction), delay: 0, onClick, From 1cc8736ba4b105d6241f72e34afb82937d13b351 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 12 Sep 2023 19:13:01 -0400 Subject: [PATCH 06/15] use icon on web --- .../Notification/LocalNotification/BrowserNotifications.js | 3 ++- src/libs/Notification/LocalNotification/index.website.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.js b/src/libs/Notification/LocalNotification/BrowserNotifications.js index 99e274d42d1f..811ed7fabce0 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.js +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.js @@ -128,12 +128,13 @@ export default { }); }, - pushModifiedExpenseNotification({reportAction, onClick}) { + pushModifiedExpenseNotification({reportAction, onClick}, usesIcon = false) { push({ title: _.map(reportAction.person, (f) => f.text).join(), body: ReportUtils.getModifiedExpenseMessage(reportAction), delay: 0, onClick, + icon: usesIcon ? EXPENSIFY_ICON_URL : '', }); }, diff --git a/src/libs/Notification/LocalNotification/index.website.js b/src/libs/Notification/LocalNotification/index.website.js index ef5ee101b16d..6c2a409ccdcb 100644 --- a/src/libs/Notification/LocalNotification/index.website.js +++ b/src/libs/Notification/LocalNotification/index.website.js @@ -9,7 +9,7 @@ function showUpdateAvailableNotification() { } function showModifiedExpenseNotification({report, reportAction, onClick}) { - BrowserNotifications.pushModifiedExpenseNotification({report, reportAction, onClick}); + BrowserNotifications.pushModifiedExpenseNotification({report, reportAction, onClick}, true); } export default { From b6be9920ffe509a385418a63840867559888285a Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 12 Sep 2023 19:22:37 -0400 Subject: [PATCH 07/15] log reason for no notification --- src/libs/actions/Report.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 2965594488ca..17fa6a5bc9bc 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1568,6 +1568,7 @@ function shouldShowReportActionNotification(reportID, action = null, isRemote = // Only show notifications for supported types of report actions if (action && !_.contains([CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE], action.actionName)) { + Log.info(`${tag} No notification because this action type is not supported`, false, {actionName: action.actionName}); return false; } From 6db3f487c899ce4ddbacf3526cad27a4b27ab7b0 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Wed, 13 Sep 2023 17:55:04 -0400 Subject: [PATCH 08/15] use the alert in the payload as the notification message --- .../CustomNotificationProvider.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/com/expensify/chat/customairshipextender/CustomNotificationProvider.java b/android/app/src/main/java/com/expensify/chat/customairshipextender/CustomNotificationProvider.java index 0ba77f809b19..c60476ad3f0a 100644 --- a/android/app/src/main/java/com/expensify/chat/customairshipextender/CustomNotificationProvider.java +++ b/android/app/src/main/java/com/expensify/chat/customairshipextender/CustomNotificationProvider.java @@ -106,7 +106,8 @@ protected NotificationCompat.Builder onExtendBuilder(@NonNull Context context, @ if (payload.containsKey(ONYX_DATA_KEY)) { Objects.requireNonNull(payload.get(ONYX_DATA_KEY)).isNull(); Log.d(TAG, "payload contains onxyData"); - applyMessageStyle(context, builder, payload, arguments.getNotificationId()); + String alert = message.getExtra(PushMessage.EXTRA_ALERT); + applyMessageStyle(context, builder, payload, arguments.getNotificationId(), alert); } } catch (Exception e) { Log.e(TAG, "Failed to parse conversation, falling back to default notification style. SendID=" + message.getSendId(), e); @@ -163,7 +164,7 @@ public Bitmap getCroppedBitmap(Bitmap bitmap) { * @param payload Notification payload, which contains all the data we need to build the notifications. * @param notificationID Current notification ID */ - private void applyMessageStyle(@NonNull Context context, NotificationCompat.Builder builder, JsonMap payload, int notificationID) { + private void applyMessageStyle(@NonNull Context context, NotificationCompat.Builder builder, JsonMap payload, int notificationID, String alert) { long reportID = payload.get("reportID").getLong(-1); if (reportID == -1) { return; @@ -181,7 +182,9 @@ private void applyMessageStyle(@NonNull Context context, NotificationCompat.Buil String name = messageData.get("person").getList().get(0).getMap().get("text").getString(); String avatar = messageData.get("avatar").getString(); String accountID = Integer.toString(messageData.get("actorAccountID").getInt(-1)); - String message = messageData.get("message").getList().get(0).getMap().get("text").getString(); + + // Use the formatted alert message from the backend. Otherwise fallback on the message in the Onyx data. + String message = alert != null ? alert : messageData.get("message").getList().get(0).getMap().get("text").getString(); String conversationName = payload.get("roomName") == null ? "" : payload.get("roomName").getString(""); // Retrieve or create the Person object who sent the latest report comment From 0223dc59a7193af5c44003fc885be02676b0be0d Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Sat, 16 Sep 2023 00:03:40 -0400 Subject: [PATCH 09/15] add comment for matching the backend --- src/libs/ReportUtils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index c95bf505879d..c88d0828b195 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1495,6 +1495,9 @@ function getProperSchemaForModifiedExpenseMessage(newValue, oldValue, valueName, /** * Get the report action message when expense has been modified. * + * ModifiedExpense::getNewDotComment in Web-Expensify should match this. + * If we change this function be sure to update the backend as well. + * * @param {Object} reportAction * @returns {String} */ From 9ed14a9f8a33dc4bfb3be1da98c55012269460cc Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Mon, 18 Sep 2023 14:34:06 +0800 Subject: [PATCH 10/15] fix selecting the wrong report action to notify for --- src/libs/ReportActionsUtils.js | 5 +++++ src/libs/actions/Report.js | 2 +- src/libs/actions/User.js | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index fde847bd9bfc..d02f10cbf123 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -630,6 +630,10 @@ function isReportActionAttachment(reportAction) { return _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : isReportMessageAttachment(message); } +function isNotifiableReportAction(reportAction) { + return reportAction && _.contains([CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE], reportAction.actionName); +} + export { getSortedReportActions, getLastVisibleAction, @@ -668,4 +672,5 @@ export { isTaskAction, getAllReportActions, isReportActionAttachment, + isNotifiableReportAction, }; diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 4d984502ab71..4536fae1fe34 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1567,7 +1567,7 @@ function shouldShowReportActionNotification(reportID, action = null, isRemote = } // Only show notifications for supported types of report actions - if (action && !_.contains([CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE], action.actionName)) { + if (!ReportActionsUtils.isNotifiableReportAction(action)) { Log.info(`${tag} No notification because this action type is not supported`, false, {actionName: action.actionName}); return false; } diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 7482c13268e4..df7cf04abac5 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -531,8 +531,8 @@ function triggerNotifications(onyxUpdates) { const reportID = update.key.replace(ONYXKEYS.COLLECTION.REPORT_ACTIONS, ''); const reportActions = _.values(update.value); - const sortedReportActions = ReportActionsUtils.getSortedReportActions(reportActions); - Report.showReportActionNotification(reportID, _.last(sortedReportActions)); + const notifiableActions = _.filter(reportActions, (action) => ReportActionsUtils.isNotifiableReportAction(action)); + _.each(notifiableActions, (action) => Report.showReportActionNotification(reportID, action)); }); } From eceb13fe9c214cec0e66acdb5fccc8ad2347bf55 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Mon, 18 Sep 2023 18:07:28 +0800 Subject: [PATCH 11/15] suppress false positives --- src/libs/ReportActionsUtils.js | 1 + src/libs/actions/User.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index d02f10cbf123..bd64158184ed 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -630,6 +630,7 @@ function isReportActionAttachment(reportAction) { return _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : isReportMessageAttachment(message); } +// eslint-disable-next-line rulesdir/no-negated-variables function isNotifiableReportAction(reportAction) { return reportAction && _.contains([CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE], reportAction.actionName); } diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index df7cf04abac5..d629b4ae0fbf 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -531,6 +531,8 @@ function triggerNotifications(onyxUpdates) { const reportID = update.key.replace(ONYXKEYS.COLLECTION.REPORT_ACTIONS, ''); const reportActions = _.values(update.value); + + // eslint-disable-next-line rulesdir/no-negated-variables const notifiableActions = _.filter(reportActions, (action) => ReportActionsUtils.isNotifiableReportAction(action)); _.each(notifiableActions, (action) => Report.showReportActionNotification(reportID, action)); }); From 63ecfa2699486db368848314ebc5576009393a60 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Mon, 25 Sep 2023 10:43:55 +0800 Subject: [PATCH 12/15] use comma with space separator --- src/libs/Notification/LocalNotification/BrowserNotifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.js b/src/libs/Notification/LocalNotification/BrowserNotifications.js index 811ed7fabce0..ca2cfc73866d 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.js +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.js @@ -130,7 +130,7 @@ export default { pushModifiedExpenseNotification({reportAction, onClick}, usesIcon = false) { push({ - title: _.map(reportAction.person, (f) => f.text).join(), + title: _.map(reportAction.person, (f) => f.text).join(', '), body: ReportUtils.getModifiedExpenseMessage(reportAction), delay: 0, onClick, From 682be4a179a4d6b6b16e149fa1d778d98055778a Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 26 Sep 2023 09:33:56 +0800 Subject: [PATCH 13/15] add jsdocs --- .../Notification/LocalNotification/index.desktop.js | 12 ++++++++++++ .../Notification/LocalNotification/index.website.js | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/libs/Notification/LocalNotification/index.desktop.js b/src/libs/Notification/LocalNotification/index.desktop.js index 6e526da2bd1f..a70141e7d9db 100644 --- a/src/libs/Notification/LocalNotification/index.desktop.js +++ b/src/libs/Notification/LocalNotification/index.desktop.js @@ -1,5 +1,11 @@ import BrowserNotifications from './BrowserNotifications'; +/** + * @param {Object} options + * @param {Object} options.report + * @param {Object} options.reportAction + * @param {Function} options.onClick + */ function showCommentNotification({report, reportAction, onClick}) { BrowserNotifications.pushReportCommentNotification({report, reportAction, onClick}); } @@ -8,6 +14,12 @@ function showUpdateAvailableNotification() { BrowserNotifications.pushUpdateAvailableNotification(); } +/** + * @param {Object} options + * @param {Object} options.report + * @param {Object} options.reportAction + * @param {Function} options.onClick + */ function showModifiedExpenseNotification({report, reportAction, onClick}) { BrowserNotifications.pushModifiedExpenseNotification({report, reportAction, onClick}); } diff --git a/src/libs/Notification/LocalNotification/index.website.js b/src/libs/Notification/LocalNotification/index.website.js index 6c2a409ccdcb..0ecb8bcbb81d 100644 --- a/src/libs/Notification/LocalNotification/index.website.js +++ b/src/libs/Notification/LocalNotification/index.website.js @@ -1,5 +1,11 @@ import BrowserNotifications from './BrowserNotifications'; +/** + * @param {Object} options + * @param {Object} options.report + * @param {Object} options.reportAction + * @param {Function} options.onClick + */ function showCommentNotification({report, reportAction, onClick}) { BrowserNotifications.pushReportCommentNotification({report, reportAction, onClick}, true); } @@ -8,6 +14,12 @@ function showUpdateAvailableNotification() { BrowserNotifications.pushUpdateAvailableNotification(); } +/** + * @param {Object} options + * @param {Object} options.report + * @param {Object} options.reportAction + * @param {Function} options.onClick + */ function showModifiedExpenseNotification({report, reportAction, onClick}) { BrowserNotifications.pushModifiedExpenseNotification({report, reportAction, onClick}, true); } From b1730125421b6b868c581c58135cfcd3d175dcb5 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 26 Sep 2023 09:48:22 +0800 Subject: [PATCH 14/15] add notifiable actionName --- tests/actions/ReportTest.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/actions/ReportTest.js b/tests/actions/ReportTest.js index 62109089665c..06d8304111cb 100644 --- a/tests/actions/ReportTest.js +++ b/tests/actions/ReportTest.js @@ -503,7 +503,9 @@ describe('actions/Report', () => { it('should show a notification for report action updates with shouldNotify', () => { const TEST_USER_ACCOUNT_ID = 1; const REPORT_ID = '1'; - const REPORT_ACTION = {}; + const REPORT_ACTION = { + actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, + }; // Setup user and pusher listeners return TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID) From b8791c3d3d49b31c4bc86e1d7ba6d10131784995 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 26 Sep 2023 12:31:28 +0800 Subject: [PATCH 15/15] DRY up notification params Co-authored-by: Marc Glasser --- src/libs/actions/Report.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 13db759a93ed..296abc6a9cfa 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1648,18 +1648,15 @@ function showReportActionNotification(reportID, reportAction) { Log.info('[LocalNotification] Creating notification'); const report = allReports[reportID]; + const notificationParams = { + report, + reportAction, + onClick: () => Navigation.navigate(ROUTES.getReportRoute(reportID)), + }; if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) { - LocalNotification.showModifiedExpenseNotification({ - report, - reportAction, - onClick: () => Navigation.navigate(ROUTES.getReportRoute(reportID)), - }); + LocalNotification.showModifiedExpenseNotification(notificationParams); } else { - LocalNotification.showCommentNotification({ - report, - reportAction, - onClick: () => Navigation.navigate(ROUTES.getReportRoute(reportID)), - }); + LocalNotification.showCommentNotification(notificationParams); } notifyNewAction(reportID, reportAction.actorAccountID, reportAction.reportActionID);