From fb355188487bcd1e4185b8a034f95560cc28946d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 4 Mar 2020 11:46:34 -0500 Subject: Fixing post sorting by stickied on front end. Fixes #575 --- ui/src/utils.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ui/src/utils.ts') diff --git a/ui/src/utils.ts b/ui/src/utils.ts index d531a7ca..5987070c 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -729,7 +729,11 @@ function convertCommentSortType(sort: SortType): CommentSortType { } } -export function postSort(posts: Array, sort: SortType) { +export function postSort( + posts: Array, + sort: SortType, + communityType: boolean +) { // First, put removed and deleted comments at the bottom, then do your other sorts if ( sort == SortType.TopAll || @@ -740,13 +744,17 @@ export function postSort(posts: Array, sort: SortType) { ) { posts.sort( (a, b) => - +a.removed - +b.removed || +a.deleted - +b.deleted || b.score - a.score + +a.removed - +b.removed || + +a.deleted - +b.deleted || + (communityType && +b.stickied - +a.stickied) || + b.score - a.score ); } else if (sort == SortType.New) { posts.sort( (a, b) => +a.removed - +b.removed || +a.deleted - +b.deleted || + (communityType && +b.stickied - +a.stickied) || b.published.localeCompare(a.published) ); } else if (sort == SortType.Hot) { @@ -754,6 +762,7 @@ export function postSort(posts: Array, sort: SortType) { (a, b) => +a.removed - +b.removed || +a.deleted - +b.deleted || + (communityType && +b.stickied - +a.stickied) || hotRankPost(b) - hotRankPost(a) ); } -- cgit v1.2.3