From ba12a99476465ef2708834434ffd316bf479d48e Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 2 Aug 2023 15:32:56 +0700 Subject: [PATCH 1/2] fix: cannot leave public room in offline after adding comment --- src/libs/actions/Report.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 38e3676492d4..97dd87e100b5 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1729,6 +1729,8 @@ function openReportFromDeepLink(url, isAuthenticated) { * @param {String} reportID */ function leaveRoom(reportID) { + const report = lodashGet(allReports, `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {}); + const reportKeys = _.keys(report); API.write( 'LeaveRoom', { @@ -1745,6 +1747,15 @@ function leaveRoom(reportID) { }, }, ], + // Manually clear the report using merge. Should not use set here since it would cause race condition + // if it was called right after a merge. + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: _.object(reportKeys, Array(reportKeys.length).fill(null)), + }, + ], failureData: [ { onyxMethod: Onyx.METHOD.SET, From c474122affaa3029a56ced51b5fc55aefdf9b1bf Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 2 Aug 2023 16:17:14 +0700 Subject: [PATCH 2/2] get correct report --- 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 97dd87e100b5..26fbc70b3ad8 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1729,7 +1729,7 @@ function openReportFromDeepLink(url, isAuthenticated) { * @param {String} reportID */ function leaveRoom(reportID) { - const report = lodashGet(allReports, `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {}); + const report = lodashGet(allReports, [reportID], {}); const reportKeys = _.keys(report); API.write( 'LeaveRoom',