summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post.tsx
diff options
context:
space:
mode:
authorD Anzorge <d.anzorge@gmail.com>2020-01-28 19:52:28 +0100
committerD Anzorge <d.anzorge@gmail.com>2020-01-28 20:14:08 +0100
commit8bcf191a1d17e4bda4ea3304efa98855d4c2590b (patch)
tree7182392c318af21afa976d07761e8e91feff74e3 /ui/src/components/post.tsx
parent8849dc07cfeda43e69047b820c2cbdd12cd45129 (diff)
Add sorting by old (date, ascending) to comment frontend
Diffstat (limited to 'ui/src/components/post.tsx')
-rw-r--r--ui/src/components/post.tsx19
1 files changed, 19 insertions, 0 deletions
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index 9ea275ce..36621248 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -235,6 +235,18 @@ export class Post extends Component<any, PostState> {
onChange={linkEvent(this, this.handleCommentSortChange)}
/>
</label>
+ <label
+ className={`btn btn-sm btn-secondary pointer ${this.state
+ .commentSort === CommentSortType.Old && 'active'}`}
+ >
+ {i18n.t('old')}
+ <input
+ type="radio"
+ value={CommentSortType.Old}
+ checked={this.state.commentSort === CommentSortType.Old}
+ onChange={linkEvent(this, this.handleCommentSortChange)}
+ />
+ </label>
</div>
);
}
@@ -317,6 +329,13 @@ export class Post extends Component<any, PostState> {
+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) =>