saving chat for each flow
This commit is contained in:
parent
4e1f1b58bd
commit
6c98a6e474
2 changed files with 6 additions and 3 deletions
|
|
@ -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(()=>{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue