diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 0b1f45006fc2..21ff401c72c7 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -155,9 +155,6 @@ export default { // Is report data loading? IS_LOADING_REPORT_DATA: 'isLoadingReportData', - // Is policy data loading? - IS_LOADING_POLICY_DATA: 'isLoadingPolicyData', - // Is Keyboard shortcuts modal open? IS_SHORTCUTS_MODAL_OPEN: 'isShortcutsModalOpen', diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index b51666f0e86f..1df9a904ea20 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -99,26 +99,6 @@ function updateLastAccessedWorkspace(policyID) { Onyx.set(ONYXKEYS.LAST_ACCESSED_WORKSPACE_POLICY_ID, policyID); } -/** - * Used to update ALL of the policies at once. If a policy is present locally, but not in the policies object passed here it will be removed. - * @param {Object} policyCollection - object of policy key and partial policy object - */ -function updateAllPolicies(policyCollection) { - // Clear out locally cached policies that have been deleted (i.e. they exist locally but not in our new policy collection object) - _.each(allPolicies, (policy, key) => { - if (policyCollection[key]) { - return; - } - - Onyx.set(key, null); - }); - - // Set all the policies - _.each(policyCollection, (policyData, key) => { - Onyx.merge(key, {...policyData, alertMessage: '', errors: null}); - }); -} - /** * Delete the workspace * @@ -168,40 +148,6 @@ function deleteWorkspace(policyID, reports) { } } -/** - * Fetches policy list from the API and saves a simplified version in Onyx, optionally creating a new policy first. - * - * More specifically, this action will: - * 1. Optionally create a new policy. - * 2. Fetch policy summaries. - * 3. Optionally navigate to the new policy. - * 4. Then fetch full policies. - * - * This way, we ensure that there's no race condition between creating the new policy and fetching existing ones, - * and we also don't have to wait for full policies to load before navigating to the new policy. - */ -function getPolicyList() { - Onyx.set(ONYXKEYS.IS_LOADING_POLICY_DATA, true); - DeprecatedAPI.GetPolicySummaryList() - .then((data) => { - if (data.jsonCode !== 200) { - Onyx.set(ONYXKEYS.IS_LOADING_POLICY_DATA, false); - return; - } - - const policyCollection = _.reduce(data.policySummaryList, (memo, policy) => ({ - ...memo, - [`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`]: getSimplifiedPolicyObject(policy, false), - }), {}); - - if (!_.isEmpty(policyCollection)) { - updateAllPolicies(policyCollection); - } - - Onyx.set(ONYXKEYS.IS_LOADING_POLICY_DATA, false); - }); -} - /** * @param {String} policyID */ @@ -978,7 +924,6 @@ function openWorkspaceInvitePage(policyID, clientMemberEmails) { } export { - getPolicyList, loadFullPolicy, removeMembers, addMembersToWorkspace, diff --git a/src/libs/actions/Welcome.js b/src/libs/actions/Welcome.js index 41c559093941..d1130b9450b2 100644 --- a/src/libs/actions/Welcome.js +++ b/src/libs/actions/Welcome.js @@ -17,7 +17,6 @@ let isReadyPromise = new Promise((resolve) => { let isFirstTimeNewExpensifyUser; let isLoadingReportData = true; -let isLoadingPolicyData = true; let email = ''; /** @@ -28,7 +27,7 @@ let email = ''; * - Whether we have loaded all reports the server knows about */ function checkOnReady() { - if (!_.isBoolean(isFirstTimeNewExpensifyUser) || isLoadingPolicyData || isLoadingReportData) { + if (!_.isBoolean(isFirstTimeNewExpensifyUser) || isLoadingReportData) { return; } @@ -53,15 +52,6 @@ Onyx.connect({ }, }); -Onyx.connect({ - key: ONYXKEYS.IS_LOADING_POLICY_DATA, - initWithStoredValues: false, - callback: (val) => { - isLoadingPolicyData = val; - checkOnReady(); - }, -}); - const allReports = {}; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, @@ -77,7 +67,7 @@ Onyx.connect({ const allPolicies = {}; Onyx.connect({ - key: ONYXKEYS.COLLECTION.REPORT, + key: ONYXKEYS.COLLECTION.POLICY, callback: (val, key) => { if (!val || !key) { return;