mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: prevent duplicate links in nextBlocks when updating block
This commit is contained in:
parent
98d79488a9
commit
f86fc1a179
@ -291,30 +291,34 @@ const Diagrams = () => {
|
|||||||
entity.getSourcePort().getOptions()?.label ===
|
entity.getSourcePort().getOptions()?.label ===
|
||||||
BlockPorts.nextBlocksOutPort
|
BlockPorts.nextBlocksOutPort
|
||||||
) {
|
) {
|
||||||
const nextBlocks = [
|
// Only add the link if targetId exists, skip if targetId is null
|
||||||
...(previousData?.nextBlocks || []),
|
if (!targetId) {
|
||||||
...(targetId ? [targetId] : []),
|
return;
|
||||||
];
|
}
|
||||||
|
// Only add the link if targetId doesn't already exist in nextBlocks
|
||||||
|
if (!previousData?.nextBlocks?.includes(targetId)) {
|
||||||
|
const nextBlocks = [...(previousData?.nextBlocks || []), targetId];
|
||||||
|
|
||||||
updateBlock(
|
updateBlock(
|
||||||
{
|
{
|
||||||
id: sourceId,
|
id: sourceId,
|
||||||
params: {
|
params: {
|
||||||
nextBlocks,
|
nextBlocks,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
onSuccess(data) {
|
||||||
onSuccess(data) {
|
if (data.id)
|
||||||
if (data.id)
|
updateCachedBlock({
|
||||||
updateCachedBlock({
|
id: targetId,
|
||||||
id: targetId,
|
payload: {
|
||||||
payload: {
|
previousBlocks: [data.id as any],
|
||||||
previousBlocks: [data.id as any],
|
},
|
||||||
},
|
});
|
||||||
});
|
},
|
||||||
},
|
},
|
||||||
},
|
);
|
||||||
);
|
}
|
||||||
} else if (
|
} else if (
|
||||||
// @ts-expect-error undefined attr
|
// @ts-expect-error undefined attr
|
||||||
entity.getSourcePort().getOptions().label ===
|
entity.getSourcePort().getOptions().label ===
|
||||||
|
Loading…
Reference in New Issue
Block a user