1 import { Component } from 'inferno';
3 CommentNode as CommentNodeI,
8 } from '../interfaces';
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;
23 showCommunity?: boolean;
24 sort?: CommentSortType;
28 export class CommentNodes extends Component<
32 constructor(props: any, context: any) {
33 super(props, context);
38 <div className="comments">
39 {this.sorter().map(node => (
42 noIndent={this.props.noIndent}
43 viewOnly={this.props.viewOnly}
44 locked={this.props.locked}
45 moderators={this.props.moderators}
46 admins={this.props.admins}
47 postCreatorId={this.props.postCreatorId}
48 markable={this.props.markable}
49 showCommunity={this.props.showCommunity}
50 sort={this.props.sort}
51 sortType={this.props.sortType}
58 sorter(): Array<CommentNodeI> {
59 if (this.props.sort !== undefined) {
60 commentSort(this.props.nodes, this.props.sort);
61 } else if (this.props.sortType !== undefined) {
62 commentSortSortType(this.props.nodes, this.props.sortType);
65 return this.props.nodes;