diff --git a/vite/src/pages/flow_moty.jsx b/vite/src/pages/flow_moty.jsx index d55dcda..b8dfba9 100644 --- a/vite/src/pages/flow_moty.jsx +++ b/vite/src/pages/flow_moty.jsx @@ -98,6 +98,7 @@ export function FlowMoty(){ const { history, status, reset, sendMessage, setStatus, audioOutput, setAudioOutput, stop:stopChat, audioUrl }=useChat(); + const refHistory=useRef(); const { transcript, @@ -620,8 +621,9 @@ export function FlowMoty(){ } function exportFile(isTest=false){ - const user_input = history.find(msg => msg.role === 'user' && msg.content!='...'); + const user_input = refHistory.current?.find(msg => msg.role === 'user' && msg.content!='...'); const default_image=!(user_input && user_input.content.trim() !== ''); + console.log('export file', default_image, padInput) const order=parseInt(data?.id)||Math.floor(Math.random()*10+5); const delay=order*2000; @@ -629,9 +631,9 @@ export function FlowMoty(){ // setTimeout(()=>{ if(isTest) { - sendOsc(OSC_ADDRESS.EXPORT, `${getFileId(padInput)}#generated`); // Send OSC export message + sendOsc(OSC_ADDRESS.EXPORT, `${padInput}#generated`); // Send OSC export message }else{ - sendOsc(OSC_ADDRESS.EXPORT, `${getFileId(padInput)}#${default_image?'default':'generated'}`); // Send OSC export message + sendOsc(OSC_ADDRESS.EXPORT, `${padInput}#${default_image?'default':'generated'}`); // Send OSC export message } @@ -670,6 +672,10 @@ export function FlowMoty(){ } + useEffect(()=>{ + refHistory.current=history; + },[history]); + useEffect(()=>{ if(!lastOsc) return; diff --git a/vite/src/util/useUser.jsx b/vite/src/util/useUser.jsx index c88f3b9..508b6b2 100644 --- a/vite/src/util/useUser.jsx +++ b/vite/src/util/useUser.jsx @@ -30,6 +30,9 @@ export function UserProvider({children}) { function getFileId(){ + + console.log('getFileid', userId); + if(!userId){ if(data?.id){ return `PC${data.id.toString().padStart(2,'0')}`;