From 8ebc94e732a7060b057cefbf5974a75e9221aa3e Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Wed, 26 Jul 2023 14:59:07 +0100 Subject: [PATCH 1/2] use the clientPolicyIDToLastModified over policyIDList --- src/libs/actions/App.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index 860d4ce47b91..b48f082798e9 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -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', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) + .map((policy) => [policy.id, policy.lastModified || 0]) + .object() + .value(); +} + /** * @param {String} locale */ @@ -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(); From 03f85c70083fca8d015572a6571324f321a31c19 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Thu, 27 Jul 2023 14:01:40 +0100 Subject: [PATCH 2/2] Update default value to empty string --- src/libs/actions/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index b48f082798e9..1455f52e891a 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -69,7 +69,7 @@ function getNonOptimisticPolicyIDs(policies) { */ function getNonOptimisticPolicyIDToLastModifiedMap(policies) { return _.chain(policies) - .reject((policy) => lodashGet(policy, 'pendingAction', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) + .reject((policy) => lodashGet(policy, 'pendingAction', '') === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) .map((policy) => [policy.id, policy.lastModified || 0]) .object() .value();