diff options
author | Dessalines <tyhou13@gmx.com> | 2019-10-13 12:53:41 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-10-13 12:53:41 -0700 |
commit | c4bb6028c4c4e1f4ebf70a7ab0a4b3c42007404e (patch) | |
tree | d9006ca887ada9ef11b81c4929975da12d9739ce /ui/src/components/post.tsx | |
parent | 4a5957cc9f19d0b3f898c82e43a861a7c6cf2114 (diff) |
Sort removed and deleted comments at the bottom.
- Fixes #279
Diffstat (limited to 'ui/src/components/post.tsx')
-rw-r--r-- | ui/src/components/post.tsx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index 07bddd34..43489327 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -234,12 +234,19 @@ export class Post extends Component<any, PostState> { sortTree(tree: Array<CommentNodeI>) { + // First, put removed and deleted comments at the bottom, then do your other sorts if (this.state.commentSort == CommentSortType.Top) { - tree.sort((a, b) => b.comment.score - a.comment.score); + tree.sort((a, b) => (+a.comment.removed - +b.comment.removed) || + (+a.comment.deleted - +b.comment.deleted ) || + (b.comment.score - a.comment.score)); } else if (this.state.commentSort == CommentSortType.New) { - tree.sort((a, b) => b.comment.published.localeCompare(a.comment.published)); + tree.sort((a, b) => (+a.comment.removed - +b.comment.removed) || + (+a.comment.deleted - +b.comment.deleted ) || + (b.comment.published.localeCompare(a.comment.published))); } else if (this.state.commentSort == CommentSortType.Hot) { - tree.sort((a, b) => hotRank(b.comment) - hotRank(a.comment)); + tree.sort((a, b) => (+a.comment.removed - +b.comment.removed) || + (+a.comment.deleted - +b.comment.deleted ) || + (hotRank(b.comment) - hotRank(a.comment))); } for (let node of tree) { |