From 22cfedcaffd89125821b516e07850ba95e25288a Mon Sep 17 00:00:00 2001 From: sabaimran Date: Mon, 5 Aug 2024 09:48:00 +0530 Subject: [PATCH] In the chat history side panel, order conversations by updated time --- .../app/components/sidePanel/chatHistorySidePanel.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx b/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx index 9f094803..9f601f31 100644 --- a/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx +++ b/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx @@ -64,6 +64,7 @@ interface ChatHistory { agent_avatar: string; compressed: boolean; created: string; + updated: string; showSidePanel: (isEnabled: boolean) => void; } @@ -391,6 +392,7 @@ function SessionsAndFiles(props: SessionsAndFilesProps) { props.subsetOrganizedData[timeGrouping].map( (chatHistory) => ( {data[timeGrouping].map((chatHistory) => ( { - const chatDate = new Date(chatHistory.created); + chatSessions.forEach((chatSessionMetadata) => { + const chatDate = new Date(chatSessionMetadata.updated); const diffTime = Math.abs(currentDate.getTime() - chatDate.getTime()); const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); @@ -745,14 +748,14 @@ export default function SidePanel(props: SidePanelProps) { if (!groupedData[timeGrouping]) { groupedData[timeGrouping] = []; } - groupedData[timeGrouping].push(chatHistory); + groupedData[timeGrouping].push(chatSessionMetadata); // Add to subsetOrganizedData if less than 8 if (numAdded < 8) { if (!subsetOrganizedData[timeGrouping]) { subsetOrganizedData[timeGrouping] = []; } - subsetOrganizedData[timeGrouping].push(chatHistory); + subsetOrganizedData[timeGrouping].push(chatSessionMetadata); numAdded++; } });