Refactor flowStore.ts: Comment out unused code and remove unnecessary variables

This commit is contained in:
anovazzi1 2024-02-21 16:28:30 -03:00
commit f58c2d4964

View file

@ -311,29 +311,29 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
getFilterEdge: [], getFilterEdge: [],
onConnect: (connection) => { onConnect: (connection) => {
const dark = useDarkStore.getState().dark; const dark = useDarkStore.getState().dark;
const commonMarkerProps = { // const commonMarkerProps = {
type: MarkerType.ArrowClosed, // type: MarkerType.ArrowClosed,
width: 20, // width: 20,
height: 20, // height: 20,
color: dark ? "#555555" : "#000000", // color: dark ? "#555555" : "#000000",
}; // };
const inputTypes = INPUT_TYPES; // const inputTypes = INPUT_TYPES;
const outputTypes = OUTPUT_TYPES; // const outputTypes = OUTPUT_TYPES;
const findNode = useFlowStore // const findNode = useFlowStore
.getState() // .getState()
.nodes.find( // .nodes.find(
(node) => node.id === connection.source || node.id === connection.target // (node) => node.id === connection.source || node.id === connection.target
); // );
const sourceType = findNode?.data?.type; // const sourceType = findNode?.data?.type;
let isIoIn = false; // let isIoIn = false;
let isIoOut = false; // let isIoOut = false;
if (sourceType) { // if (sourceType) {
isIoIn = inputTypes.has(sourceType); // isIoIn = inputTypes.has(sourceType);
isIoOut = outputTypes.has(sourceType); // isIoOut = outputTypes.has(sourceType);
} // }
let newEdges: Edge[] = []; let newEdges: Edge[] = [];
get().setEdges((oldEdges) => { get().setEdges((oldEdges) => {
@ -345,12 +345,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
sourceHandle: scapeJSONParse(connection.sourceHandle!), sourceHandle: scapeJSONParse(connection.sourceHandle!),
}, },
style: { stroke: "#555" }, style: { stroke: "#555" },
className: className:"stroke-foreground stroke-connection",
((scapeJSONParse(connection.targetHandle!) as targetHandleType)
.type === "Text"
? "stroke-foreground "
: "stroke-foreground ") + " stroke-connection",
markerEnd: isIoIn || isIoOut ? { ...commonMarkerProps } : undefined,
}, },
oldEdges oldEdges
); );