Merge branch 'dev' of github.com:LDataCentric/reactFlow into dev

This commit is contained in:
Lucas Oliveira 2023-02-23 16:22:25 -03:00
commit 2eeaf06585
2 changed files with 4 additions and 7 deletions

View file

@ -34,7 +34,7 @@ export default function Chat({ reactFlowInstance }) {
return true; return true;
} }
function validateChatNodes(){ 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 false;
} }
return true; return true;
@ -108,11 +108,7 @@ export default function Chat({ reactFlowInstance }) {
let message = chatValue; let message = chatValue;
setChatValue(""); setChatValue("");
addChatHistory(message, true); addChatHistory(message, true);
sendAll({ sendAll({...reactFlowInstance.toObject(),message}).then((r) => {addChatHistory(r.data.messsage, false);});
message,
nodes: JSON.stringify(reactFlowInstance.getNodes()),
edges: JSON.stringify(reactFlowInstance.getEdges()),
}).then((r) => {addChatHistory(r.data.messsage, false);});
} else { } else {
setErrorData({title: 'Error sending message', list:['Chat nodes are missing.']}) setErrorData({title: 'Error sending message', list:['Chat nodes are missing.']})
} }

View file

@ -50,6 +50,7 @@ export default function FlowPage({ flow }) {
const [edges, setEdges, onEdgesChange] = useEdgesState( const [edges, setEdges, onEdgesChange] = useEdgesState(
flow.data?.edges ?? [] flow.data?.edges ?? []
); );
const {setViewport} = useReactFlow()
useEffect(() => { useEffect(() => {
if (reactFlowInstance && flow) { if (reactFlowInstance && flow) {
@ -62,7 +63,7 @@ export default function FlowPage({ flow }) {
setNodes(flow?.data?.nodes ?? []); setNodes(flow?.data?.nodes ?? []);
setEdges(flow?.data?.edges ?? []); setEdges(flow?.data?.edges ?? []);
if (reactFlowInstance) { if (reactFlowInstance) {
reactFlowInstance.setViewport( setViewport(
flow?.data?.viewport ?? { x: 1, y: 0, zoom: 1 } flow?.data?.viewport ?? { x: 1, y: 0, zoom: 1 }
); );
} }