Skip to content

Commit

Permalink
Add comment why use merge instead of set when deleting report
Browse files Browse the repository at this point in the history
  • Loading branch information
wildan-m committed Nov 23, 2024
1 parent 6b0b5a6 commit 5e5026d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,8 @@ function getDeleteTrackExpenseInformation(

if (shouldDeleteTransactionThread) {
optimisticData.push(
// Use merge instead of set to avoid deleting the report too quickly, which could cause a brief "not found" page to appear.
// The remaining parts of the report object will be removed after the API call is successful.
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
Expand Down Expand Up @@ -1836,6 +1838,8 @@ function getDeleteTrackExpenseInformation(
},
];

// Ensure that any remaining data is removed upon successful completion, even if the server sends a report removal response.
// This is done to prevent the removal update from lingering in the applyHTTPSOnyxUpdates function.
if (shouldDeleteTransactionThread && transactionThread) {
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -5768,6 +5772,8 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor

if (shouldDeleteTransactionThread) {
optimisticData.push(
// Use merge instead of set to avoid deleting the report too quickly, which could cause a brief "not found" page to appear.
// The remaining parts of the report object will be removed after the API call is successful.
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
Expand Down Expand Up @@ -5878,6 +5884,8 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor
},
];

// Ensure that any remaining data is removed upon successful completion, even if the server sends a report removal response.
// This is done to prevent the removal update from lingering in the applyHTTPSOnyxUpdates function.
if (shouldDeleteTransactionThread && transactionThread) {
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2915,6 +2915,8 @@ function leaveGroupChat(reportID: string) {
});
}

// Ensure that any remaining data is removed upon successful completion, even if the server sends a report removal response.
// This is done to prevent the removal update from lingering in the applyHTTPSOnyxUpdates function.
const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down

0 comments on commit 5e5026d

Please sign in to comment.