From 7ef97cfd81b9948c63fb49e909f1391c3acc2e53 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 1 Mar 2024 15:42:22 +0000 Subject: [PATCH] fix abort --- application/api/user/routes.py | 2 +- frontend/src/conversation/Conversation.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 86742572..4d4c1b41 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -36,7 +36,7 @@ def delete_conversation(): @user.route("/api/get_conversations", methods=["get"]) def get_conversations(): # provides a list of conversations - conversations = conversations_collection.find().sort("date", -1) + conversations = conversations_collection.find().sort("date", -1).limit(30) list_conversations = [] for conversation in conversations: list_conversations.append({"id": str(conversation["_id"]), "name": conversation["name"]}) diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index 5ed43d93..f39fd641 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -41,9 +41,11 @@ export default function Conversation() { useEffect(() => { return () => { - fetchStream.current && fetchStream.current.abort(); //abort previous stream + if (status !== 'idle') { + fetchStream.current && fetchStream.current.abort(); //abort previous stream + } } - }, [conversationId]) + }, [status]) useEffect(() => { const observerCallback: IntersectionObserverCallback = (entries) => { entries.forEach((entry) => {