From de53d2455301982a81dbfafc0dea862ceb89ae98 Mon Sep 17 00:00:00 2001 From: shallegro Date: Thu, 4 Jul 2024 12:58:17 +0300 Subject: [PATCH] safer max in array --- .../shared/services/dag-manager-unsorted.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/webapp-common/shared/services/dag-manager-unsorted.service.ts b/src/app/webapp-common/shared/services/dag-manager-unsorted.service.ts index c140884c..9107cfff 100644 --- a/src/app/webapp-common/shared/services/dag-manager-unsorted.service.ts +++ b/src/app/webapp-common/shared/services/dag-manager-unsorted.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { DagManagerService, DagModelItem } from '@ngneat/dag'; +import {maxInArray} from '@common/shared/utils/helpers.util'; @Injectable({ providedIn: 'root' @@ -41,7 +42,7 @@ export class DagManagerUnsortedService extends DagManage }); // Sort nodes by level and position them - const maxLevel = Math.max(...nodeLevels.values()); + const maxLevel = maxInArray(Array.from(nodeLevels.values())); itemsArray.forEach(item => { const level = maxLevel - nodeLevels.get(item.stepId); if (!result[level]) {