Merge pull request #1092 from Hexastack/963-fix-duplicate-block-links
Some checks failed
Build and Push Docker API Image / build-and-push (push) Has been cancelled
Build and Push Docker Base Image / build-and-push (push) Has been cancelled
Build and Push Docker UI Image / build-and-push (push) Has been cancelled

Prevent duplicate links in nextBlocks during block updates
This commit is contained in:
Med Marrouchi 2025-06-09 11:33:32 +01:00 committed by GitHub
commit 2a3f15b84d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -264,6 +264,19 @@ const Diagrams = () => {
return;
}
const sourceId = entity.getSourcePort().getParent().getOptions()
.id as string;
const targetId = entity.getTargetPort().getParent().getOptions()
.id as string;
const previousData = getBlockFromCache(sourceId!);
// Only add the link if targetId doesn't already exist in nextBlocks
if (previousData?.nextBlocks?.includes(targetId)) {
model.removeLink(link);
return;
}
link.setLocked(true);
link.registerListener({
selectionChanged(event: any) {
@ -280,17 +293,15 @@ const Diagrams = () => {
}
});
const sourceId = entity.getSourcePort().getParent().getOptions()
.id as string;
const targetId = entity.getTargetPort().getParent().getOptions()
.id as string;
const previousData = getBlockFromCache(sourceId!);
if (
// @ts-expect-error undefined attr
entity.getSourcePort().getOptions()?.label ===
BlockPorts.nextBlocksOutPort
) {
// Only add the link if targetId exists, skip if targetId is null
if (!targetId) {
return;
}
const nextBlocks = [
...(previousData?.nextBlocks || []),
...(targetId ? [targetId] : []),