From d14b37f3f0273166185c33fb2bdfd959e6811731 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 31 Oct 2024 19:16:04 +0300 Subject: [PATCH] remove unnecessary isLoading field from approval workflow --- src/libs/WorkflowUtils.ts | 1 - src/libs/actions/Workflow.ts | 48 +++---------------- .../WorkspaceWorkflowsApprovalsCreatePage.tsx | 1 - .../WorkspaceWorkflowsApprovalsEditPage.tsx | 2 - src/types/onyx/ApprovalWorkflow.ts | 5 -- 5 files changed, 6 insertions(+), 51 deletions(-) diff --git a/src/libs/WorkflowUtils.ts b/src/libs/WorkflowUtils.ts index 3a43c0bc4eca..1b13d270b689 100644 --- a/src/libs/WorkflowUtils.ts +++ b/src/libs/WorkflowUtils.ts @@ -13,7 +13,6 @@ const INITIAL_APPROVAL_WORKFLOW: ApprovalWorkflowOnyx = { usedApproverEmails: [], isDefault: false, action: CONST.APPROVAL_WORKFLOW.ACTION.CREATE, - isLoading: false, }; type GetApproversParams = { diff --git a/src/libs/actions/Workflow.ts b/src/libs/actions/Workflow.ts index 7da3807f6bd3..83a1b9ea61e4 100644 --- a/src/libs/actions/Workflow.ts +++ b/src/libs/actions/Workflow.ts @@ -63,11 +63,9 @@ function createApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork const optimisticData: OnyxUpdate[] = [ { - onyxMethod: Onyx.METHOD.MERGE, + onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, - value: { - isLoading: true, - }, + value: null, }, { onyxMethod: Onyx.METHOD.MERGE, @@ -80,11 +78,6 @@ function createApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork ]; const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.APPROVAL_WORKFLOW, - value: {...approvalWorkflow, isLoading: false}, - }, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -96,11 +89,6 @@ function createApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork ]; const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.APPROVAL_WORKFLOW, - value: null, - }, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -139,11 +127,9 @@ function updateApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork const optimisticData: OnyxUpdate[] = [ { - onyxMethod: Onyx.METHOD.MERGE, + onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, - value: { - isLoading: true, - }, + value: null, }, { onyxMethod: Onyx.METHOD.MERGE, @@ -156,11 +142,6 @@ function updateApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork ]; const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.APPROVAL_WORKFLOW, - value: {...approvalWorkflow, isLoading: false}, - }, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -173,11 +154,6 @@ function updateApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork ]; const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.APPROVAL_WORKFLOW, - value: null, - }, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -213,11 +189,9 @@ function removeApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork const optimisticData: OnyxUpdate[] = [ { - onyxMethod: Onyx.METHOD.MERGE, + onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.APPROVAL_WORKFLOW, - value: { - isLoading: true, - }, + value: null, }, { onyxMethod: Onyx.METHOD.MERGE, @@ -230,11 +204,6 @@ function removeApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork ]; const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.APPROVAL_WORKFLOW, - value: {...approvalWorkflow, isLoading: false}, - }, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, @@ -246,11 +215,6 @@ function removeApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork ]; const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.APPROVAL_WORKFLOW, - value: null, - }, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, diff --git a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsCreatePage.tsx b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsCreatePage.tsx index 5b3962b91372..d1991617c9a6 100644 --- a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsCreatePage.tsx +++ b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsCreatePage.tsx @@ -81,7 +81,6 @@ function WorkspaceWorkflowsApprovalsCreatePage({policy, isLoadingReportData = tr onFixTheErrorsLinkPressed={() => { formRef.current?.scrollTo({y: 0, animated: true}); }} - isLoading={approvalWorkflow?.isLoading} buttonText={translate('workflowsCreateApprovalsPage.submitButton')} containerStyles={[styles.mb5, styles.mh5]} enabledWhenOffline diff --git a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx index f54ab2a8e613..d67dd564057c 100644 --- a/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx +++ b/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx @@ -107,7 +107,6 @@ function WorkspaceWorkflowsApprovalsEditPage({policy, isLoadingReportData = true availableMembers: [...currentApprovalWorkflow.members, ...defaultWorkflowMembers], usedApproverEmails, action: CONST.APPROVAL_WORKFLOW.ACTION.EDIT, - isLoading: false, errors: null, }); setInitialApprovalWorkflow(currentApprovalWorkflow); @@ -147,7 +146,6 @@ function WorkspaceWorkflowsApprovalsEditPage({policy, isLoadingReportData = true onFixTheErrorsLinkPressed={() => { formRef.current?.scrollTo({y: 0, animated: true}); }} - isLoading={approvalWorkflow?.isLoading} buttonText={translate('common.save')} containerStyles={[styles.mb5, styles.mh5]} enabledWhenOffline diff --git a/src/types/onyx/ApprovalWorkflow.ts b/src/types/onyx/ApprovalWorkflow.ts index bafb1c78a8de..8c3f7ed555f0 100644 --- a/src/types/onyx/ApprovalWorkflow.ts +++ b/src/types/onyx/ApprovalWorkflow.ts @@ -100,11 +100,6 @@ type ApprovalWorkflowOnyx = Omit & { */ action: ValueOf; - /** - * Whether we are waiting for the API action to complete - */ - isLoading: boolean; - /** * List of available members that can be selected in the workflow */