Skip to content
Closed
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
18 changes: 18 additions & 0 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,23 @@ function fetchIOUReportByID(iouReportID, chatReportID, shouldRedirectIfEmpty = f
});
}

function fetchIOUReportAndAllIOUActions(chatReportID, iouReportID) {
return API.GetIOUReportAndIOUActions({
reportID: chatReportID,
iouReportID: iouReportID,
}).then((resp) => {setLocalIOUReportData
const simplifiedIOUReport = getSimplifiedIOUReport(resp.iouReport, chatReportID);
console.log('Put IOUReport in Onyx: ' + JSON.stringify(formattedIOUReport));

Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT_IOUS, simplifiedIOUReport);

const indexedData = _.indexBy(data.history, 'sequenceNumber');
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, indexedData);

return resp;
});
}

/**
* If an iouReport is open (has an IOU, but is not yet paid) then we sync the reportIDs of both chatReport and
* iouReport in Onyx, simplifying IOU data retrieval and reducing necessary API calls when displaying IOU components:
Expand Down Expand Up @@ -1574,6 +1591,7 @@ export {
fetchActions,
fetchOrCreateChatReport,
fetchChatReportsByIDs,
fetchIOUReportAndAllIOUActions,
fetchIOUReportByID,
fetchIOUReportByIDAndUpdateChatReport,
addAction,
Expand Down
7 changes: 7 additions & 0 deletions src/libs/deprecatedAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ function GetIOUReport(parameters) {
return Network.post(commandName, parameters);
}

function GetIOUReportAndIOUActions(parameters) {
const commandName = 'GetIOUReportAndIOUActions';
requireParameters(['reportID', 'iouReportID'], parameters, commandName);
return Network.post(commandName, parameters);
}

/**
* @returns {Promise}
* @param {String} policyID
Expand Down Expand Up @@ -946,6 +952,7 @@ export {
GetShortLivedAuthToken,
GetStatementPDF,
GetIOUReport,
GetIOUReportAndIOUActions,
GetFullPolicy,
GetPolicySummaryList,
GetReportSummaryList,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/IOUDetailsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class IOUDetailsModal extends Component {
}

fetchData() {
Report.fetchIOUReportByID(this.props.route.params.iouReportID, this.props.route.params.chatReportID, true);
Report.fetchIOUReportAndAllIOUActions(this.props.route.params.chatReportID, this.props.route.params.iouReportID);
}

/**
Expand Down