Add sorting by old (date, ascending) to comment frontend
This commit is contained in:
parent
8849dc07cf
commit
8bcf191a1d
3 changed files with 21 additions and 0 deletions
19
ui/src/components/post.tsx
vendored
19
ui/src/components/post.tsx
vendored
|
@ -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) =>
|
||||
|
|
1
ui/src/interfaces.ts
vendored
1
ui/src/interfaces.ts
vendored
|
@ -47,6 +47,7 @@ export enum CommentSortType {
|
|||
Hot,
|
||||
Top,
|
||||
New,
|
||||
Old,
|
||||
}
|
||||
|
||||
export enum ListingType {
|
||||
|
|
1
ui/src/translations/en.ts
vendored
1
ui/src/translations/en.ts
vendored
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue