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

Send lastModified with the UpdateWorkspaceCustomUnit and UpdateWorkspaceCustomUnitRate commands #12162

Merged
merged 5 commits into from
Nov 1, 2022
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
9 changes: 7 additions & 2 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function getSimplifiedPolicyObject(fullPolicyOrPolicySummary, isFromFullPolicy)
avatar: fullPolicyOrPolicySummary.avatar
|| lodashGet(fullPolicyOrPolicySummary, 'value.avatar', ''),
customUnits: lodashGet(fullPolicyOrPolicySummary, 'value.customUnits', {}),
lastModified: lodashGet(fullPolicyOrPolicySummary, 'value.lastModified', 0),
};
}

Expand Down Expand Up @@ -490,8 +491,9 @@ function hideWorkspaceAlertMessage(policyID) {
* @param {String} policyID
* @param {Object} currentCustomUnit
* @param {Object} newCustomUnit
* @param {Number} lastModified
*/
function updateWorkspaceCustomUnit(policyID, currentCustomUnit, newCustomUnit) {
function updateWorkspaceCustomUnit(policyID, currentCustomUnit, newCustomUnit, lastModified) {
const optimisticData = [
{
onyxMethod: 'merge',
Expand Down Expand Up @@ -543,6 +545,7 @@ function updateWorkspaceCustomUnit(policyID, currentCustomUnit, newCustomUnit) {

API.write('UpdateWorkspaceCustomUnit', {
policyID,
lastModified,
customUnit: JSON.stringify(newCustomUnit),
}, {optimisticData, successData, failureData});
}
Expand All @@ -552,8 +555,9 @@ function updateWorkspaceCustomUnit(policyID, currentCustomUnit, newCustomUnit) {
* @param {Object} currentCustomUnitRate
* @param {String} customUnitID
* @param {Object} newCustomUnitRate
* @param {Number} lastModified
*/
function updateCustomUnitRate(policyID, currentCustomUnitRate, customUnitID, newCustomUnitRate) {
function updateCustomUnitRate(policyID, currentCustomUnitRate, customUnitID, newCustomUnitRate, lastModified) {
const optimisticData = [
{
onyxMethod: 'merge',
Expand Down Expand Up @@ -616,6 +620,7 @@ function updateCustomUnitRate(policyID, currentCustomUnitRate, customUnitID, new
API.write('UpdateWorkspaceCustomUnitRate', {
policyID,
customUnitID,
lastModified,
customUnitRate: JSON.stringify(newCustomUnitRate),
}, {optimisticData, successData, failureData});
}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/workspace/reimburse/WorkspaceReimburseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const propTypes = {
),
outputCurrency: PropTypes.string,
hasVBA: PropTypes.bool,
lastModified: PropTypes.number,
}).isRequired,

/** Information about the network */
Expand Down Expand Up @@ -160,7 +161,7 @@ class WorkspaceReimburseView extends React.Component {
customUnitID: this.state.unitID,
name: this.state.unitName,
attributes: {unit: value},
});
}, this.props.policy.lastModified);
}

debounceUpdateOnCursorMove(event) {
Expand All @@ -183,7 +184,7 @@ class WorkspaceReimburseView extends React.Component {
Policy.updateCustomUnitRate(this.props.policy.id, currentCustomUnitRate, this.state.unitID, {
...currentCustomUnitRate,
rate: numValue * CONST.POLICY.CUSTOM_UNIT_RATE_BASE_OFFSET,
});
}, this.props.policy.lastModified);
}

render() {
Expand Down