fix: threads sorting order after updated (#4319)

This commit is contained in:
Louis 2024-12-23 14:09:02 +07:00 committed by GitHub
parent 1f4c00dc41
commit 365cdfa333
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -200,12 +200,12 @@ export const updateThreadAtom = atom(
)
// sort new threads based on updated at
threads.sort((thread1, thread2) => {
const aDate = new Date(thread1.updated ?? 0)
const bDate = new Date(thread2.updated ?? 0)
return bDate.getTime() - aDate.getTime()
threads.sort((a, b) => {
return ((a.metadata?.updated_at as number) ?? 0) >
((b.metadata?.updated_at as number) ?? 0)
? -1
: 1
})
set(threadsAtom, threads)
}
)