1 import { Component } from 'inferno';
2 import { CommentSortType } from '../interfaces';
4 CommentNode as CommentNodeI,
8 } from 'lemmy-js-client';
9 import { commentSort, commentSortSortType } from '../utils';
10 import { CommentNode } from './comment-node';
12 interface CommentNodesState {}
14 interface CommentNodesProps {
15 nodes: Array<CommentNodeI>;
16 moderators?: Array<CommunityUser>;
17 admins?: Array<UserView>;
18 postCreatorId?: number;
24 showContext?: boolean;
25 showCommunity?: boolean;
26 sort?: CommentSortType;
28 enableDownvotes: boolean;
31 export class CommentNodes extends Component<
35 constructor(props: any, context: any) {
36 super(props, context);
41 <div className="comments">
42 {this.sorter().map(node => (
46 noBorder={this.props.noBorder}
47 noIndent={this.props.noIndent}
48 viewOnly={this.props.viewOnly}
49 locked={this.props.locked}
50 moderators={this.props.moderators}
51 admins={this.props.admins}
52 postCreatorId={this.props.postCreatorId}
53 markable={this.props.markable}
54 showContext={this.props.showContext}
55 showCommunity={this.props.showCommunity}
56 sort={this.props.sort}
57 sortType={this.props.sortType}
58 enableDownvotes={this.props.enableDownvotes}
65 sorter(): Array<CommentNodeI> {
66 if (this.props.sort !== undefined) {
67 commentSort(this.props.nodes, this.props.sort);
68 } else if (this.props.sortType !== undefined) {
69 commentSortSortType(this.props.nodes, this.props.sortType);
72 return this.props.nodes;