From ad7e9753101a463ac7acb4dc55cefc005c53f900 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 23 Feb 2023 15:00:39 -0300 Subject: [PATCH 1/2] sending flow object to backend --- space_flow/src/components/chatComponent/index.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/space_flow/src/components/chatComponent/index.tsx b/space_flow/src/components/chatComponent/index.tsx index f5e09213a..32acc5699 100644 --- a/space_flow/src/components/chatComponent/index.tsx +++ b/space_flow/src/components/chatComponent/index.tsx @@ -108,11 +108,7 @@ export default function Chat({ reactFlowInstance }) { let message = chatValue; setChatValue(""); addChatHistory(message, true); - sendAll({ - message, - nodes: JSON.stringify(reactFlowInstance.getNodes()), - edges: JSON.stringify(reactFlowInstance.getEdges()), - }).then((r) => {addChatHistory(r.data.messsage, false);}); + sendAll({...reactFlowInstance.toObject(),message}).then((r) => {addChatHistory(r.data.messsage, false);}); } else { setErrorData({title: 'Error sending message', list:['Chat nodes are missing.']}) } From 912dff60ec25be36ed7e0cd993ec353322b752a0 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 23 Feb 2023 15:49:17 -0300 Subject: [PATCH 2/2] chat input validation removed --- space_flow/src/components/chatComponent/index.tsx | 2 +- space_flow/src/pages/FlowPage/index.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/space_flow/src/components/chatComponent/index.tsx b/space_flow/src/components/chatComponent/index.tsx index 32acc5699..446bf9b61 100644 --- a/space_flow/src/components/chatComponent/index.tsx +++ b/space_flow/src/components/chatComponent/index.tsx @@ -34,7 +34,7 @@ export default function Chat({ reactFlowInstance }) { return true; } function validateChatNodes(){ - if(!reactFlowInstance.getNodes().some((n)=> (n.type === 'chatOutputNode')) || !reactFlowInstance.getNodes().some((n)=> (n.type === 'chatInputNode'))){ + if(!reactFlowInstance.getNodes().some((n)=> (n.type === 'chatOutputNode'))){ return false; } return true; diff --git a/space_flow/src/pages/FlowPage/index.tsx b/space_flow/src/pages/FlowPage/index.tsx index cbab1f045..61abd40d5 100644 --- a/space_flow/src/pages/FlowPage/index.tsx +++ b/space_flow/src/pages/FlowPage/index.tsx @@ -52,6 +52,7 @@ export default function FlowPage({ flow }) { const [edges, setEdges, onEdgesChange] = useEdgesState( flow.data?.edges ?? [] ); + const {setViewport} = useReactFlow() useEffect(() => { if (reactFlowInstance && flow) { @@ -64,7 +65,7 @@ export default function FlowPage({ flow }) { setNodes(flow?.data?.nodes ?? []); setEdges(flow?.data?.edges ?? []); if (reactFlowInstance) { - reactFlowInstance.setViewport( + setViewport( flow?.data?.viewport ?? { x: 1, y: 0, zoom: 1 } ); }