📅 fix: Conversation grouping and labeling for prior years (#4180)

This commit is contained in:
Danny Avila 2024-09-21 18:50:04 -04:00 committed by GitHub
parent b0a48fd693
commit eba2c9a032
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 79 additions and 5 deletions

View file

@ -6,7 +6,6 @@ import {
parseISO,
startOfDay,
startOfYear,
startOfToday,
isWithinInterval,
} from 'date-fns';
import { EModelEndpoint, LocalStorageKeys } from 'librechat-data-provider';
@ -40,7 +39,7 @@ export const dateKeys = {
};
const getGroupName = (date: Date) => {
const now = new Date();
const now = new Date(Date.now());
if (isToday(date)) {
return dateKeys.today;
}
@ -95,7 +94,7 @@ export const groupConversationsByDate = (
const seenConversationIds = new Set();
const groups = new Map();
const today = startOfToday();
const now = new Date(Date.now());
conversations.forEach((conversation) => {
if (!conversation || seenConversationIds.has(conversation.conversationId)) {
@ -103,7 +102,13 @@ export const groupConversationsByDate = (
}
seenConversationIds.add(conversation.conversationId);
const date = conversation.updatedAt ? parseISO(conversation.updatedAt) : today;
let date: Date;
if (conversation.updatedAt) {
date = parseISO(conversation.updatedAt);
} else {
date = now;
}
const groupName = getGroupName(date);
if (!groups.has(groupName)) {
groups.set(groupName, []);