mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(replies): sort by timestamp
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user