fix(applyChanges): handle empty flows + addNodes/addEdges closes #3770

This commit is contained in:
moklick
2024-01-08 11:35:59 +01:00
parent e6bee0aae6
commit 1efd3ee3d5
+13 -7
View File
@@ -54,20 +54,26 @@ function applyChanges(changes: any[], elements: any[]): any[] {
return changes.filter((c) => c.type === 'reset').map((c) => c.item);
}
let remainingChanges = changes;
let remainingChanges = [];
const updatedElements: any[] = [];
for (const change of changes) {
if (change.type === 'add') {
updatedElements.push(change.item);
} else {
remainingChanges.push(change);
}
}
for (const item of elements) {
const nextChanges: any[] = [];
const _remainingChanges: any[] = [];
for (const c of remainingChanges) {
if (c.type === 'add') {
updatedElements.push(c.item);
} else if (c.id === item.id) {
nextChanges.push(c);
for (const change of remainingChanges) {
if (change.id === item.id) {
nextChanges.push(change);
} else {
_remainingChanges.push(c);
_remainingChanges.push(change);
}
}