From da70c0ef1a038c02f7d3e498bf8161593e98ded4 Mon Sep 17 00:00:00 2001 From: Prasetya Aria Wibawa Date: Fri, 4 Mar 2022 11:37:55 +0700 Subject: [PATCH] check looping from length of requestedEntities Signed-off-by: Prasetya Aria Wibawa --- .../components/Cards/OwnershipCard/useAggregatedEntities.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/org/src/components/Cards/OwnershipCard/useAggregatedEntities.ts b/plugins/org/src/components/Cards/OwnershipCard/useAggregatedEntities.ts index 45595acb78..e6ef55b32b 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/useAggregatedEntities.ts +++ b/plugins/org/src/components/Cards/OwnershipCard/useAggregatedEntities.ts @@ -70,7 +70,6 @@ export function useAggregatedEntities( const outstandingEntities = new Map>(); const processedEntities = new Set(); requestedEntities.push(entity); - let isLoop = true; let currentEntity = entity; const kinds = entityFilterKind ?? ['Component', 'API', 'System']; @@ -79,7 +78,7 @@ export function useAggregatedEntities( error, value: componentsWithCounters, } = useAsync(async () => { - while (isLoop) { + while (requestedEntities.length > 0) { const childRelations = getEntityRelations( currentEntity, RELATION_PARENT_OF, @@ -106,12 +105,11 @@ export function useAggregatedEntities( ); requestedEntities.shift(); processedEntities.add(currentEntity.metadata.name); + // always set currentEntity to the first element of array requestedEntities currentEntity = requestedEntities[0]; - if (requestedEntities.length === 0) isLoop = false; } const owners = Array.from(processedEntities); - const ownedAggregationEntitiesList = await catalogApi.getEntities({ filter: [ {