From 24d6889b242024387f46dd84099cb9f66f050f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CShriya?= Date: Wed, 21 Aug 2024 05:50:04 +0530 Subject: [PATCH] abort stream when conversationId updates --- frontend/src/conversation/Conversation.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index 1ac6d24d..551c6ac6 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -54,13 +54,9 @@ export default function Conversation() { } }, []); - useEffect(() => { - return () => { - if (status !== 'idle') { - fetchStream.current && fetchStream.current.abort(); //abort previous stream - } - }; - }, [status]); + useEffect(()=>{ + fetchStream.current && fetchStream.current.abort(); + },[conversationId]); useEffect(() => { const observerCallback: IntersectionObserverCallback = (entries) => {