feat(replies): sort by timestamp

This commit is contained in:
plebeius.eth
2024-04-23 16:10:44 +02:00
parent a89f70f88c
commit 35572ded55
+3 -1
View File
@@ -17,12 +17,14 @@ const useRepliesAndAccountReplies = (comment: Comment) => {
}, [flattenedReplies, accountComments]);
const repliesAndNotYetPublishedReplies = useMemo(() => {
return [
const repliesSortedByVotes = [
// put the author's unpublished replies at the top, latest first (reverse)
...accountRepliesNotYetPublished.reverse(),
// put the published replies after,
...(flattenedReplies || []),
];
// sort by timestamp
return repliesSortedByVotes.sort((a: Comment, b: Comment) => a.timestamp - b.timestamp);
}, [flattenedReplies, accountRepliesNotYetPublished]);
return repliesAndNotYetPublishedReplies;