From 230337aef99fa6989dd5f4537a4378de4e17ede6 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Thu, 16 May 2024 17:13:49 +0530 Subject: [PATCH] refactor: remove early return check when products list is undefined --- .../modules/product/src/services/product-module-service.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/modules/product/src/services/product-module-service.ts b/packages/modules/product/src/services/product-module-service.ts index 5ce5ba0be4..3f43a92c5a 100644 --- a/packages/modules/product/src/services/product-module-service.ts +++ b/packages/modules/product/src/services/product-module-service.ts @@ -929,9 +929,6 @@ export default class ProductModuleService< updatedCollections.map(async (collection, i) => { const input = normalizedInput.find((c) => c.id === collection.id) const productsToUpdate = (input as any)?.products - if (!productsToUpdate) { - return { ...collection, products: [] } - } await this.productService_.update( { @@ -941,7 +938,7 @@ export default class ProductModuleService< sharedContext ) - if (productsToUpdate.length > 0) { + if (productsToUpdate?.length > 0) { await this.productService_.update( productsToUpdate.map((p) => ({ id: p.id, @@ -951,7 +948,7 @@ export default class ProductModuleService< ) } - return { ...collection, products: productsToUpdate } + return { ...collection, products: productsToUpdate || [] } }) )