diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-09-01 11:54:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-01 11:54:51 -0700 |
commit | 3e96373903b337f4883e706efee88b47511734a6 (patch) | |
tree | 14d3b804eb196ade4bf97844b78fc0081553dea8 | |
parent | 4cd3ddecadfaad1e1711b916760590cd18fba675 (diff) | |
download | voidsky-3e96373903b337f4883e706efee88b47511734a6.tar.zst |
Sort thread replies by likes (#1356)
* Sort replies by likes * Types fix
-rw-r--r-- | src/state/models/content/post-thread.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/state/models/content/post-thread.ts b/src/state/models/content/post-thread.ts index 85ed13cb4..7e3650948 100644 --- a/src/state/models/content/post-thread.ts +++ b/src/state/models/content/post-thread.ts @@ -296,7 +296,11 @@ function sortThread(item: MaybeThreadItem) { if (modScore(a.moderation) !== modScore(b.moderation)) { return modScore(a.moderation) - modScore(b.moderation) } - return b.post.indexedAt.localeCompare(a.post.indexedAt) // newest + if (a.post.likeCount === b.post.likeCount) { + return b.post.indexedAt.localeCompare(a.post.indexedAt) // newest + } else { + return (b.post.likeCount || 0) - (a.post.likeCount || 0) // most likes + } }) item.replies.forEach(reply => sortThread(reply)) } |