Skip to content

Commit

Permalink
fix: prompts sort (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
peppescg authored Dec 17, 2024
1 parent 4bc3cbc commit 7b70afe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ function getGroup(differenceInMs: number, promptDate: Date): string {
}

export function groupPromptsByRelativeDate(prompts: Prompt[]) {
const grouped = prompts.reduce((groups, prompt) => {
const promptsSorted = prompts.sort(
(a, b) =>
new Date(b.conversation_timestamp).getTime() -
new Date(a.conversation_timestamp).getTime()
);

const grouped = promptsSorted.reduce((groups, prompt) => {
const promptDate = new Date(prompt.conversation_timestamp);
const now = new Date();
const differenceInMs = now.getTime() - promptDate.getTime();
Expand Down

0 comments on commit 7b70afe

Please sign in to comment.