Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: loading indicator display when deleting vague distance Expense #51940

Merged
merged 21 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
return;
}
if (parentReportAction) {
const urlToNavigateBack = IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true);
Navigation.goBack(urlToNavigateBack);
IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true);
return;
}
}
Expand Down
46 changes: 26 additions & 20 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5689,27 +5689,28 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo
// build Onyx data

// Onyx operations to delete the transaction, update the IOU report action and chat report action
const reportActionsOnyxUpdates: OnyxUpdate[] = [];
const onyxUpdates: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
value: {
[reportAction.reportActionID]: shouldDeleteIOUReport
? null
: {
pendingAction: null,
},
},
},
];
reportActionsOnyxUpdates.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
value: {
[reportAction.reportActionID]: shouldDeleteIOUReport
? null
: {
pendingAction: null,
},
},
});

if (reportPreviewAction?.reportActionID) {
onyxUpdates.push({
reportActionsOnyxUpdates.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
Expand Down Expand Up @@ -5746,12 +5747,12 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo
}

// added operations to update IOU report and chat report
reportActionsOnyxUpdates.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
value: updatedReportAction,
});
onyxUpdates.push(
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
value: updatedReportAction,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`,
Expand Down Expand Up @@ -5802,9 +5803,14 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo
);
}

Onyx.update(onyxUpdates);

return urlToNavigateBack;
// First, update the reportActions to ensure related actions are not displayed.
Onyx.update(reportActionsOnyxUpdates).then(() => {
Navigation.goBack(urlToNavigateBack);
InteractionManager.runAfterInteractions(() => {
// After navigation, update the remaining data.
Onyx.update(onyxUpdates);
});
});
}

/**
Expand Down
Loading