saving chat for each flow

This commit is contained in:
anovazzi1 2023-02-24 17:20:33 -03:00
commit 6c98a6e474
2 changed files with 6 additions and 3 deletions

View file

@ -25,11 +25,12 @@ export default function Chat({flow, reactFlowInstance }) {
newChat.push({ message, isSend });
return newChat;
});
updateFlow({..._.cloneDeep(flow),chat:chatHistory})
};
useEffect(()=>{
// setChatHistory(flow.chat)
updateFlow({..._.cloneDeep(flow),chat:chatHistory})
},[chatHistory])
useEffect(()=>{
setChatHistory(flow.chat)
console.log(flow.chat)
},[flow])
useEffect(()=>{

View file

@ -83,12 +83,14 @@ export function TabsProvider({children}){
setTabIndex(flows.length);
}
function updateFlow(newFlow:flow){
console.log(newFlow)
setFlows(prevState=>{
const newFlows = [...prevState];
const index = newFlows.findIndex(flow=>flow.id===newFlow.id)
if(index!==-1){
newFlows[index].data = newFlow.data
newFlows[index].name = newFlow.name
newFlows[index].chat = newFlow.chat
}
return newFlows;
});