From 0818a3d72320beb84bfa3475aaa0fc2341270ad0 Mon Sep 17 00:00:00 2001 From: Aleksandr Vishniakov Date: Wed, 25 Dec 2024 05:22:44 +0200 Subject: [PATCH] fix: auto load threads after migration to cookie --- .../organisms/sidebar/threadHistory/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/organisms/sidebar/threadHistory/index.tsx b/frontend/src/components/organisms/sidebar/threadHistory/index.tsx index 901bb57dd5..0f485a1946 100644 --- a/frontend/src/components/organisms/sidebar/threadHistory/index.tsx +++ b/frontend/src/components/organisms/sidebar/threadHistory/index.tsx @@ -11,6 +11,7 @@ import { IThreadFilters, accessTokenState, threadHistoryState, + useAuth, useChatMessages } from '@chainlit/react-client'; @@ -35,6 +36,7 @@ export function ThreadHistory() { const [error, setError] = useState(undefined); const [isLoadingMore, setIsLoadingMore] = useState(false); const [isFetching, setIsFetching] = useState(false); + const { isAuthenticated, isReady } = useAuth(); const apiClient = useContext(ChainlitContext); const { firstInteraction, messages, threadId } = useChatMessages(); const navigate = useNavigate(); @@ -120,7 +122,13 @@ export function ThreadHistory() { } }; - if (accessToken && !isFetching && !threadHistory?.threads && !error) { + if ( + isReady && + isAuthenticated && + !isFetching && + !threadHistory?.threads && + !error + ) { fetchThreads(); }