Skip to content

Commit

Permalink
Merge pull request Expensify#23653 from Expensify/yuwen-clientPolicyI…
Browse files Browse the repository at this point in the history
…DToLastModified

Send the clientPolicyIDToLastModified in addition to the policyIDList
  • Loading branch information
MonilBhavsar authored Jul 27, 2023
2 parents 96c765d + 03f85c7 commit cd09dc9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ function getNonOptimisticPolicyIDs(policies) {
.value();
}

/**
* @param {Array} policies
* @return {Object} map of policy id to lastUpdated
*/
function getNonOptimisticPolicyIDToLastModifiedMap(policies) {
return _.chain(policies)
.reject((policy) => lodashGet(policy, 'pendingAction', '') === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD)
.map((policy) => [policy.id, policy.lastModified || 0])
.object()
.value();
}

/**
* @param {String} locale
*/
Expand Down Expand Up @@ -136,7 +148,7 @@ function openApp(isReconnecting = false) {
//
// - Look through the local report actions and reports to find the most recently modified report action or report.
// - We send this to the server so that it can compute which new chats the user needs to see and return only those as an optimization.
const params = {policyIDList: getNonOptimisticPolicyIDs(policies)};
const params = {policyIDList: getNonOptimisticPolicyIDs(policies), policyIDToLastModified: JSON.stringify(getNonOptimisticPolicyIDToLastModifiedMap(policies))};
if (isReconnecting) {
Timing.start(CONST.TIMING.CALCULATE_MOST_RECENT_LAST_MODIFIED_ACTION);
params.mostRecentReportActionLastModified = ReportActionsUtils.getMostRecentReportActionLastModified();
Expand Down

0 comments on commit cd09dc9

Please sign in to comment.