From 3a44cf5f8673454e6fbeacc94c63ce1a12f485f8 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Fri, 15 Oct 2021 18:34:48 +0200 Subject: [PATCH] refactor: iterate array, not generator in auth steps --- .../src/components/AddAppConnection/index.tsx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/web/src/components/AddAppConnection/index.tsx b/packages/web/src/components/AddAppConnection/index.tsx index 8bc422d4..f586e6e8 100644 --- a/packages/web/src/components/AddAppConnection/index.tsx +++ b/packages/web/src/components/AddAppConnection/index.tsx @@ -21,14 +21,6 @@ type Response = { [key: string]: any; } -function* authStepGenerator(steps: any[]) { - for (const step of steps) { - yield step; - } - - return; -} - export default function AddAppConnection(props: AddAppConnectionProps){ const { application, onClose } = props; const { key, fields, authenticationSteps } = application; @@ -46,16 +38,16 @@ export default function AddAppConnection(props: AddAppConnectionProps){ fields: data, }; - const stepGenerator = authStepGenerator(authenticationSteps); - - let authenticationStep; - while (!(authenticationStep = stepGenerator.next()).done) { - const step = authenticationStep.value; + let stepIndex = 0; + while (stepIndex < authenticationSteps.length) { + const step = authenticationSteps[stepIndex]; const variables = computeAuthStepVariables(step, response); const stepResponse = await processStep(step, variables); response[step.name] = stepResponse; + + stepIndex++; } onClose?.();