Skip to content

Commit

Permalink
fix: collapsedSubProcessIds should be a Set, and use `collapsedSu…
Browse files Browse the repository at this point in the history
…bProcessIds.has()` to check existence or non-existence unicorn/prefer-set-has
  • Loading branch information
csouchet committed Sep 6, 2023
1 parent bca5e64 commit 8a0c1a3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/component/registry/bpmn-model-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ export class BpmnModelRegistry {
}

function toRenderedModel(bpmnModel: BpmnModel): RenderedModel {
const collapsedSubProcessIds: string[] = bpmnModel.flowNodes
.filter(shape => {
const bpmnElement = shape.bpmnElement;
return ShapeUtil.isSubProcess(bpmnElement.kind) && (bpmnElement as ShapeBpmnSubProcess).markers.includes(ShapeBpmnMarkerKind.EXPAND);
})
.map(shape => shape.bpmnElement.id);
const collapsedSubProcessIds = new Set(
bpmnModel.flowNodes
.filter(shape => {
const bpmnElement = shape.bpmnElement;
return ShapeUtil.isSubProcess(bpmnElement.kind) && (bpmnElement as ShapeBpmnSubProcess).markers.includes(ShapeBpmnMarkerKind.EXPAND);
})
.map(shape => shape.bpmnElement.id),
);

const subprocesses: Shape[] = [];
const boundaryEvents: Shape[] = [];
Expand All @@ -82,7 +84,7 @@ function toRenderedModel(bpmnModel: BpmnModel): RenderedModel {
subprocesses.push(shape);
} else if (ShapeUtil.isBoundaryEvent(kind)) {
boundaryEvents.push(shape);
} else if (!collapsedSubProcessIds.includes(shape.bpmnElement.parentId)) {
} else if (!collapsedSubProcessIds.has(shape.bpmnElement.parentId)) {
otherFlowNodes.push(shape);
}
}
Expand Down

0 comments on commit 8a0c1a3

Please sign in to comment.