mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +00:00
In the chat history side panel, order conversations by updated time
This commit is contained in:
@@ -64,6 +64,7 @@ interface ChatHistory {
|
|||||||
agent_avatar: string;
|
agent_avatar: string;
|
||||||
compressed: boolean;
|
compressed: boolean;
|
||||||
created: string;
|
created: string;
|
||||||
|
updated: string;
|
||||||
showSidePanel: (isEnabled: boolean) => void;
|
showSidePanel: (isEnabled: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,6 +392,7 @@ function SessionsAndFiles(props: SessionsAndFilesProps) {
|
|||||||
props.subsetOrganizedData[timeGrouping].map(
|
props.subsetOrganizedData[timeGrouping].map(
|
||||||
(chatHistory) => (
|
(chatHistory) => (
|
||||||
<ChatSession
|
<ChatSession
|
||||||
|
updated={chatHistory.updated}
|
||||||
created={chatHistory.created}
|
created={chatHistory.created}
|
||||||
compressed={true}
|
compressed={true}
|
||||||
key={chatHistory.conversation_id}
|
key={chatHistory.conversation_id}
|
||||||
@@ -668,6 +670,7 @@ function ChatSessionsModal({ data, showSidePanel }: ChatSessionsModalProps) {
|
|||||||
</div>
|
</div>
|
||||||
{data[timeGrouping].map((chatHistory) => (
|
{data[timeGrouping].map((chatHistory) => (
|
||||||
<ChatSession
|
<ChatSession
|
||||||
|
updated={chatHistory.updated}
|
||||||
created={chatHistory.created}
|
created={chatHistory.created}
|
||||||
compressed={false}
|
compressed={false}
|
||||||
key={chatHistory.conversation_id}
|
key={chatHistory.conversation_id}
|
||||||
@@ -735,8 +738,8 @@ export default function SidePanel(props: SidePanelProps) {
|
|||||||
|
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
|
|
||||||
chatSessions.forEach((chatHistory) => {
|
chatSessions.forEach((chatSessionMetadata) => {
|
||||||
const chatDate = new Date(chatHistory.created);
|
const chatDate = new Date(chatSessionMetadata.updated);
|
||||||
const diffTime = Math.abs(currentDate.getTime() - chatDate.getTime());
|
const diffTime = Math.abs(currentDate.getTime() - chatDate.getTime());
|
||||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||||
|
|
||||||
@@ -745,14 +748,14 @@ export default function SidePanel(props: SidePanelProps) {
|
|||||||
if (!groupedData[timeGrouping]) {
|
if (!groupedData[timeGrouping]) {
|
||||||
groupedData[timeGrouping] = [];
|
groupedData[timeGrouping] = [];
|
||||||
}
|
}
|
||||||
groupedData[timeGrouping].push(chatHistory);
|
groupedData[timeGrouping].push(chatSessionMetadata);
|
||||||
|
|
||||||
// Add to subsetOrganizedData if less than 8
|
// Add to subsetOrganizedData if less than 8
|
||||||
if (numAdded < 8) {
|
if (numAdded < 8) {
|
||||||
if (!subsetOrganizedData[timeGrouping]) {
|
if (!subsetOrganizedData[timeGrouping]) {
|
||||||
subsetOrganizedData[timeGrouping] = [];
|
subsetOrganizedData[timeGrouping] = [];
|
||||||
}
|
}
|
||||||
subsetOrganizedData[timeGrouping].push(chatHistory);
|
subsetOrganizedData[timeGrouping].push(chatSessionMetadata);
|
||||||
numAdded++;
|
numAdded++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user