From 360f5dea95535fc263402399d896372ee404c251 Mon Sep 17 00:00:00 2001 From: Govind Kamtamneni Date: Sun, 26 May 2024 22:08:04 -0700 Subject: [PATCH] Fix chat list entry issue --- .../src/components/chat/chat-session-list.tsx | 12 ++++++++---- ui/typescript/src/layouts/header/header.tsx | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/typescript/src/components/chat/chat-session-list.tsx b/ui/typescript/src/components/chat/chat-session-list.tsx index 5ccd3c75..b3657443 100644 --- a/ui/typescript/src/components/chat/chat-session-list.tsx +++ b/ui/typescript/src/components/chat/chat-session-list.tsx @@ -28,9 +28,13 @@ export function ChatSessionList({ className, setSelectedSession: updateSelectedS // Set the first session as selected if (data.length > 0) { - const firstChatSession = data[0]; - setSelectedSession(firstChatSession); - await fetchChatMessages(firstChatSession.id); + const mostRecentChatSession = data[0]; + setSelectedSession(mostRecentChatSession); + await fetchChatMessages(mostRecentChatSession.id); + setUserInfoAtom((prevUserInfo: UserInfoProps) => ({ + ...prevUserInfo, + chatId: mostRecentChatSession.id, + })); } } fetchChatSessions().then(r => console.log(r)); @@ -46,7 +50,7 @@ export function ChatSessionList({ className, setSelectedSession: updateSelectedS } }); const data = await response.json(); - setChatsAtom(data as ChatProps[]); + setChatsAtom(data.reverse() as ChatProps[]); } // New handler for Listbox onChange event diff --git a/ui/typescript/src/layouts/header/header.tsx b/ui/typescript/src/layouts/header/header.tsx index b0cf6696..c85f1dbf 100644 --- a/ui/typescript/src/layouts/header/header.tsx +++ b/ui/typescript/src/layouts/header/header.tsx @@ -66,7 +66,7 @@ export default function Header({ className }: { className?: string }) { Semantic Search, Powered by Azure Cognitive Search + /> Semantic Search, Powered by Azure AI Search