Skip to content

Commit

Permalink
undo nest promise
Browse files Browse the repository at this point in the history
  • Loading branch information
rushatgabhane committed Mar 25, 2022
1 parent b616725 commit 6370445
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,39 +139,38 @@ function createIOUSplit(params) {
})
.then((response) => {
if (response.jsonCode !== 200) {
processIOUErrorResponse(response);
return;
return response;
}

chatReportID = response.reportID;
return API.CreateIOUSplit({
...params,
splits: JSON.stringify(params.splits),
reportID: response.reportID,
})
.then((response) => {
if (response.jsonCode !== 200) {
processIOUErrorResponse(response);
return;
}

// This data needs to go from this:
// {reportIDList: [1, 2], chatReportIDList: [3, 4]}
// to this:
// [{reportID: 1, chatReportID: 3}, {reportID: 2, chatReportID: 4}]
// in order for getIOUReportsForNewTransaction to know which IOU reports are associated with which
// chat reports
const reportParams = [];
for (let i = 0; i < response.reportIDList.length; i++) {
reportParams.push({
reportID: response.reportIDList[i],
chatReportID: response.chatReportIDList[i],
});
}
getIOUReportsForNewTransaction(reportParams);
Navigation.navigate(ROUTES.getReportRoute(chatReportID));
});
})
.then((response) => {
if (response.jsonCode !== 200) {
processIOUErrorResponse(response);
return;
}

// This data needs to go from this:
// {reportIDList: [1, 2], chatReportIDList: [3, 4]}
// to this:
// [{reportID: 1, chatReportID: 3}, {reportID: 2, chatReportID: 4}]
// in order for getIOUReportsForNewTransaction to know which IOU reports are associated with which
// chat reports
const reportParams = [];
for (let i = 0; i < response.reportIDList.length; i++) {
reportParams.push({
reportID: response.reportIDList[i],
chatReportID: response.chatReportIDList[i],
});
}
getIOUReportsForNewTransaction(reportParams);
Navigation.navigate(ROUTES.getReportRoute(chatReportID));
});
}

/**
Expand Down

0 comments on commit 6370445

Please sign in to comment.