safer max in array

This commit is contained in:
shallegro 2024-07-04 12:58:17 +03:00
parent af11a875bc
commit de53d24553

View File

@ -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<T extends DagModelItem> 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]) {