From 229a4331aeddc934748757b76b226361f93ce6dc Mon Sep 17 00:00:00 2001 From: Srikar Parsi Date: Thu, 2 Nov 2023 21:37:02 -0400 Subject: [PATCH 1/5] update subsribe on leave --- src/libs/actions/Report.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 1de15c1184cb..5ddb2355f1c9 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -2059,6 +2059,32 @@ function leaveRoom(reportID, isWorkspaceMemberLeavingWorkspaceRoom = false) { }, ]; + const failureData = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: report, + }, + ]; + + if (report.parentReportID && report.parentReportActionID) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, + value: {[report.parentReportActionID]: {childReportNotificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN}}, + }); + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, + value: {[report.parentReportActionID]: {childReportNotificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN}}, + }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, + value: {[parentReportActionID]: {childReportNotificationPreference: report.notificationPreference}}, + }); + } + API.write( 'LeaveRoom', { @@ -2067,13 +2093,7 @@ function leaveRoom(reportID, isWorkspaceMemberLeavingWorkspaceRoom = false) { { optimisticData, successData, - failureData: [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: report, - }, - ], + failureData, }, ); From 1e060e2bc927673cb8988e9da5e97bb9c7a728f4 Mon Sep 17 00:00:00 2001 From: Srikar Parsi Date: Thu, 9 Nov 2023 04:35:12 -0500 Subject: [PATCH 2/5] fix variable names --- 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 27396c875d34..638c83862cfc 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -2085,7 +2085,7 @@ function leaveRoom(reportID, isWorkspaceMemberLeavingWorkspaceRoom = false) { failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, - value: {[parentReportActionID]: {childReportNotificationPreference: report.notificationPreference}}, + value: {[report.parentReportActionID]: {childReportNotificationPreference: report.notificationPreference}}, }); } From 99ff60abb243d4192a5970e8d0b49d7e1ac40d8d Mon Sep 17 00:00:00 2001 From: Srikar Parsi Date: Thu, 21 Dec 2023 15:43:24 -0500 Subject: [PATCH 3/5] optimistic data for join room --- src/pages/home/HeaderView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 2182cc5f6359..5c0be79d1d85 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -147,7 +147,7 @@ function HeaderView(props) { icon: Expensicons.ChatBubbles, text: translate('common.join'), onSelected: Session.checkIfActionIsAllowed(() => - Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false), + Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false, props.report.parentReportID, parentReportAction), ), }); } else if ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom) { From beb66011470d5d47db7471be9fbf94a7e426857b Mon Sep 17 00:00:00 2001 From: Srikar Parsi Date: Sun, 31 Dec 2023 19:03:54 -0500 Subject: [PATCH 4/5] parent report action id --- src/pages/home/HeaderView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 5c0be79d1d85..a3dcb41d1bfc 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -147,7 +147,7 @@ function HeaderView(props) { icon: Expensicons.ChatBubbles, text: translate('common.join'), onSelected: Session.checkIfActionIsAllowed(() => - Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false, props.report.parentReportID, parentReportAction), + Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false, props.report.parentReportID, props.report.parentReportActionID), ), }); } else if ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom) { From e76dd0187889a2188d02574a74fd498ad866442d Mon Sep 17 00:00:00 2001 From: Srikar Parsi Date: Sun, 31 Dec 2023 19:08:37 -0500 Subject: [PATCH 5/5] prettier --- src/pages/home/HeaderView.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index f79cac315d71..e50f0e81b9de 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -147,7 +147,14 @@ function HeaderView(props) { icon: Expensicons.ChatBubbles, text: translate('common.join'), onSelected: Session.checkIfActionIsAllowed(() => - Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, false, props.report.parentReportID, props.report.parentReportActionID), + Report.updateNotificationPreference( + props.report.reportID, + props.report.notificationPreference, + CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, + false, + props.report.parentReportID, + props.report.parentReportActionID, + ), ), }); } else if ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom) {