mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
🖌️ style: Update conversation history groups (#1770)
* style: Add month groups to conversation history * style: Change "Last x days" to "Previous x days" to match ChatGPT * style: Add "Yesterday" to conversation groups to match ChatGPT * fix: use startOfDay for Yesterday conversation group * fix: Output month name instead of number in conversation group name * test: Validate new conversation groups are created properly * fix: Formatting of month category string was wrong
This commit is contained in:
parent
50adb1b3c6
commit
14b61fc861
2 changed files with 29 additions and 4 deletions
|
|
@ -1,4 +1,14 @@
|
|||
import { parseISO, isToday, isWithinInterval, subDays, getYear } from 'date-fns';
|
||||
import {
|
||||
parseISO,
|
||||
isToday,
|
||||
isWithinInterval,
|
||||
subDays,
|
||||
getMonth,
|
||||
getYear,
|
||||
startOfDay,
|
||||
startOfYear,
|
||||
format,
|
||||
} from 'date-fns';
|
||||
import type {
|
||||
TConversation,
|
||||
ConversationData,
|
||||
|
|
@ -11,11 +21,17 @@ const getGroupName = (date: Date) => {
|
|||
if (isToday(date)) {
|
||||
return 'Today';
|
||||
}
|
||||
if (isWithinInterval(date, { start: startOfDay(subDays(now, 1)), end: now })) {
|
||||
return 'Yesterday';
|
||||
}
|
||||
if (isWithinInterval(date, { start: subDays(now, 7), end: now })) {
|
||||
return 'Last 7 days';
|
||||
return 'Previous 7 days';
|
||||
}
|
||||
if (isWithinInterval(date, { start: subDays(now, 30), end: now })) {
|
||||
return 'Last 30 days';
|
||||
return 'Previous 30 days';
|
||||
}
|
||||
if (isWithinInterval(date, { start: startOfYear(now), end: now })) {
|
||||
return ' ' + format(date, 'MMMM');
|
||||
}
|
||||
return ' ' + getYear(date).toString();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue