-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
coderabbit-test/ai-chatbot
#4Description
I have a situation every now and then when I create a new chat that, and the saveChat takes a little bit of time, the chat.tsx router.refresh() fires too soon. How can I ensure that it waits for saveChat to finish?
This is the code that is firing before the saveChat finishes. So the assistant responds, and the saveChat finishes after the aiState.done is called.
useEffect(() => { const messagesLength = aiState.messages?.length if (messagesLength === 2) { router.refresh() } }, [aiState.messages, router])
amxv, rab657, athrael-soju, Saran33 and abeaclark
Metadata
Metadata
Assignees
Labels
No labels