1 import { Component } from 'inferno';
2 import { CommentSortType, CommentNode as CommentNodeI } from '../interfaces';
4 CommunityModeratorView,
7 } from 'lemmy-js-client';
8 import { commentSort, commentSortSortType } from '../utils';
9 import { CommentNode } from './comment-node';
11 interface CommentNodesState {}
13 interface CommentNodesProps {
14 nodes: CommentNodeI[];
15 moderators?: CommunityModeratorView[];
16 admins?: UserViewSafe[];
17 postCreatorId?: number;
23 showContext?: boolean;
24 showCommunity?: boolean;
25 sort?: CommentSortType;
27 enableDownvotes: boolean;
30 export class CommentNodes extends Component<
34 constructor(props: any, context: any) {
35 super(props, context);
40 <div className="comments">
41 {this.sorter().map(node => (
43 key={node.comment_view.comment.id}
45 noBorder={this.props.noBorder}
46 noIndent={this.props.noIndent}
47 viewOnly={this.props.viewOnly}
48 locked={this.props.locked}
49 moderators={this.props.moderators}
50 admins={this.props.admins}
51 postCreatorId={this.props.postCreatorId}
52 markable={this.props.markable}
53 showContext={this.props.showContext}
54 showCommunity={this.props.showCommunity}
55 sort={this.props.sort}
56 sortType={this.props.sortType}
57 enableDownvotes={this.props.enableDownvotes}
64 sorter(): CommentNodeI[] {
65 if (this.props.sort !== undefined) {
66 commentSort(this.props.nodes, this.props.sort);
67 } else if (this.props.sortType !== undefined) {
68 commentSortSortType(this.props.nodes, this.props.sortType);
71 return this.props.nodes;