]> Untitled Git - lemmy.git/commitdiff
Sort removed and deleted comments at the bottom.
authorDessalines <tyhou13@gmx.com>
Sun, 13 Oct 2019 19:53:41 +0000 (12:53 -0700)
committerDessalines <tyhou13@gmx.com>
Sun, 13 Oct 2019 19:53:41 +0000 (12:53 -0700)
- Fixes #279

ui/src/components/post.tsx

index 07bddd343873c2c79ab017487fb630916efc9b7a..434893272841dd0a85f6296005b84f23f720f962 100644 (file)
@@ -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) {