Skip to content

Commit

Permalink
Fixes: fix edge handler with onDelEdge (#1471)
Browse files Browse the repository at this point in the history
* fixes: Fix edge handler

* fixes: fix edge handler with onDelEdge

* fixes: fix edge handler with onDelEdge
  • Loading branch information
Fengrui-Liu authored May 13, 2024
1 parent 8d2230f commit 240f60c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions projects/app/src/components/core/workflow/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { createContext } from 'use-context-selector';
import { defaultRunningStatus } from './constants';
import { checkNodeRunStatus } from '@fastgpt/global/core/workflow/runtime/utils';
import { EventNameEnum, eventBus } from '@/web/common/utils/eventbus';
import { getHandleId } from '@fastgpt/global/core/workflow/utils';

type OnChange<ChangesType> = (changes: ChangesType[]) => void;

Expand Down Expand Up @@ -321,7 +322,7 @@ const WorkflowContextProvider = ({
item.key === props.key ? props.value : item
);
} else if (type === 'replaceInput') {
onDelEdge({ nodeId, targetHandle: props.key });
onDelEdge({ nodeId, targetHandle: getHandleId(nodeId, 'target', props.key) });
const oldInputIndex = node.data.inputs.findIndex((item) => item.key === props.key);
updateObj.inputs = node.data.inputs.filter((item) => item.key !== props.key);
setTimeout(() => {
Expand Down Expand Up @@ -350,14 +351,14 @@ const WorkflowContextProvider = ({
}
}
} else if (type === 'delInput') {
onDelEdge({ nodeId, targetHandle: props.key });
onDelEdge({ nodeId, targetHandle: getHandleId(nodeId, 'target', props.key) });
updateObj.inputs = node.data.inputs.filter((item) => item.key !== props.key);
} else if (type === 'updateOutput') {
updateObj.outputs = node.data.outputs.map((item) =>
item.key === props.key ? props.value : item
);
} else if (type === 'replaceOutput') {
onDelEdge({ nodeId, sourceHandle: props.key });
onDelEdge({ nodeId, sourceHandle: getHandleId(nodeId, 'source', props.key) });
const oldOutputIndex = node.data.outputs.findIndex((item) => item.key === props.key);
updateObj.outputs = node.data.outputs.filter((item) => item.key !== props.key);
console.log(props.value);
Expand Down Expand Up @@ -387,7 +388,7 @@ const WorkflowContextProvider = ({
}
}
} else if (type === 'delOutput') {
onDelEdge({ nodeId, sourceHandle: props.key });
onDelEdge({ nodeId, sourceHandle: getHandleId(nodeId, 'source', props.key) });
updateObj.outputs = node.data.outputs.filter((item) => item.key !== props.key);
}

Expand Down

0 comments on commit 240f60c

Please sign in to comment.