fix(reactflowUtils.ts): refactor cleanEdges function to use JSON.parse and JSON.stringify for targetHandle and sourceHandle variables to improve readability and maintainability
This commit is contained in:
parent
44686dda06
commit
32bcb08bdb
1 changed files with 15 additions and 15 deletions
|
|
@ -30,25 +30,25 @@ export function cleanEdges({
|
||||||
const sourceHandle = edge.sourceHandle; //right
|
const sourceHandle = edge.sourceHandle; //right
|
||||||
const targetHandle = edge.targetHandle; //left
|
const targetHandle = edge.targetHandle; //left
|
||||||
if (targetHandle) {
|
if (targetHandle) {
|
||||||
const field = targetHandle.split("|")[1];
|
const targetHandleObject: targetHandleType = JSON.parse(targetHandle);
|
||||||
const id =
|
const field = targetHandleObject.fieldName;
|
||||||
(targetNode.data.node.template[field]?.input_types?.join(";") ??
|
const id: targetHandleType = {
|
||||||
targetNode.data.node.template[field]?.type) +
|
type: targetNode.data.node.template[field]?.type,
|
||||||
"|" +
|
fieldName: field,
|
||||||
field +
|
id: targetNode.data.id,
|
||||||
"|" +
|
inputTypes: targetNode.data.node.template[field]?.input_types,
|
||||||
targetNode.data.id;
|
};
|
||||||
if (id !== targetHandle) {
|
if (JSON.stringify(id) !== targetHandle) {
|
||||||
newEdges = newEdges.filter((e) => e.id !== edge.id);
|
newEdges = newEdges.filter((e) => e.id !== edge.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sourceHandle) {
|
if (sourceHandle) {
|
||||||
const id = [
|
const id: sourceHandleType = {
|
||||||
sourceNode.data.type,
|
id: sourceNode.data.id,
|
||||||
sourceNode.data.id,
|
baseClasses: sourceNode.data.node.base_classes,
|
||||||
...sourceNode.data.node.base_classes,
|
dataType: sourceNode.data.type,
|
||||||
].join("|");
|
};
|
||||||
if (id !== sourceHandle) {
|
if (JSON.stringify(id) !== sourceHandle) {
|
||||||
newEdges = newEdges.filter((e) => e.id !== edge.id);
|
newEdges = newEdges.filter((e) => e.id !== edge.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue