From 69effe303397acfeae55af9cdac9f0e2facc8f56 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 20 Dec 2023 12:04:52 +0000 Subject: [PATCH] refactor: avoid unnecessary nested if condition --- packages/nocodb/src/helpers/webhookHelpers.ts | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/nocodb/src/helpers/webhookHelpers.ts b/packages/nocodb/src/helpers/webhookHelpers.ts index ff97905f1a..08ca0a74c5 100644 --- a/packages/nocodb/src/helpers/webhookHelpers.ts +++ b/packages/nocodb/src/helpers/webhookHelpers.ts @@ -307,16 +307,15 @@ export async function invokeWebhook( const data = newData[i]; const prevData = prevData ? prevData[i] : null; - if (prevData) { - // if condition is satisfied for prevData then return - if ( - await validateCondition( - testFilters || (await hook.getFilters()), - prevData, - ) - ) { - continue; - } + // if condition is satisfied for prevData then return + if ( + prevData && + (await validateCondition( + testFilters || (await hook.getFilters()), + prevData, + )) + ) { + continue; } if ( await validateCondition( @@ -332,16 +331,15 @@ export async function invokeWebhook( } newData = filteredData; } else { - if (prevData) { - // if condition is satisfied for prevData then return - if ( - await validateCondition( - testFilters || (await hook.getFilters()), - prevData, - ) - ) { - return; - } + // if condition is satisfied for prevData then return + if ( + prevData && + (await validateCondition( + testFilters || (await hook.getFilters()), + prevData, + )) + ) { + return; } if ( !(await validateCondition(