From 92d7f39c7bd55c29602aa96c934a8e7a8447de6e Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 13 Oct 2019 12:53:41 -0700 Subject: [PATCH] Sort removed and deleted comments at the bottom. - Fixes #279 --- ui/src/components/post.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index 07bddd3..4348932 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -234,12 +234,19 @@ export class Post extends Component { sortTree(tree: Array) { + // 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) {