Skip to content

Commit 7b70afe

Browse files
authored
fix: prompts sort (#9)
1 parent 4bc3cbc commit 7b70afe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib/utils.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ function getGroup(differenceInMs: number, promptDate: Date): string {
4747
}
4848

4949
export function groupPromptsByRelativeDate(prompts: Prompt[]) {
50-
const grouped = prompts.reduce((groups, prompt) => {
50+
const promptsSorted = prompts.sort(
51+
(a, b) =>
52+
new Date(b.conversation_timestamp).getTime() -
53+
new Date(a.conversation_timestamp).getTime()
54+
);
55+
56+
const grouped = promptsSorted.reduce((groups, prompt) => {
5157
const promptDate = new Date(prompt.conversation_timestamp);
5258
const now = new Date();
5359
const differenceInMs = now.getTime() - promptDate.getTime();

0 commit comments

Comments
 (0)