From a1a11e0ce7875155ca55be34ea109f1c36afb22a Mon Sep 17 00:00:00 2001 From: D Anzorge Date: Tue, 28 Jan 2020 19:52:28 +0100 Subject: [PATCH] Add sorting by old (date, ascending) to comment frontend --- ui/src/components/post.tsx | 19 +++++++++++++++++++ ui/src/interfaces.ts | 1 + ui/src/translations/en.ts | 1 + 3 files changed, 21 insertions(+) diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index 9ea275ce2..366212488 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -235,6 +235,18 @@ export class Post extends Component { onChange={linkEvent(this, this.handleCommentSortChange)} /> + ); } @@ -317,6 +329,13 @@ export class Post extends Component { +a.comment.deleted - +b.comment.deleted || b.comment.published.localeCompare(a.comment.published) ); + } else if (this.state.commentSort == CommentSortType.Old) { + tree.sort( + (a, b) => + +a.comment.removed - +b.comment.removed || + +a.comment.deleted - +b.comment.deleted || + a.comment.published.localeCompare(b.comment.published) + ); } else if (this.state.commentSort == CommentSortType.Hot) { tree.sort( (a, b) => diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index b0594e8de..f83595d77 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -47,6 +47,7 @@ export enum CommentSortType { Hot, Top, New, + Old, } export enum ListingType { diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts index c932014f8..90aff0b93 100644 --- a/ui/src/translations/en.ts +++ b/ui/src/translations/en.ts @@ -97,6 +97,7 @@ export const en = { sort_type: 'Sort type', hot: 'Hot', new: 'New', + old: 'Old', top_day: 'Top day', week: 'Week', month: 'Month',