]> Untitled Git - lemmy-ui.git/blob - src/shared/components/comment/comment-nodes.tsx
add instance url
[lemmy-ui.git] / src / shared / components / comment / comment-nodes.tsx
1 import { Component } from "inferno";
2 import { CommunityModeratorView, Language, PersonView } from "lemmy-js-client";
3 import { CommentNodeI, CommentViewType } from "../../interfaces";
4 import { CommentNode } from "./comment-node";
5
6 interface CommentNodesProps {
7   nodes: CommentNodeI[];
8   moderators?: CommunityModeratorView[];
9   admins?: PersonView[];
10   maxCommentsShown?: number;
11   noBorder?: boolean;
12   noIndent?: boolean;
13   viewOnly?: boolean;
14   locked?: boolean;
15   markable?: boolean;
16   showContext?: boolean;
17   showCommunity?: boolean;
18   enableDownvotes?: boolean;
19   viewType: CommentViewType;
20   allLanguages: Language[];
21   siteLanguages: number[];
22   hideImages?: boolean;
23 }
24
25 export class CommentNodes extends Component<CommentNodesProps, any> {
26   constructor(props: CommentNodesProps, context: any) {
27     super(props, context);
28   }
29
30   render() {
31     const maxComments = this.props.maxCommentsShown ?? this.props.nodes.length;
32
33     return (
34       <div className="comments">
35         {this.props.nodes.slice(0, maxComments).map(node => (
36           <CommentNode
37             key={node.comment_view.comment.id}
38             node={node}
39             noBorder={this.props.noBorder}
40             noIndent={this.props.noIndent}
41             viewOnly={this.props.viewOnly}
42             locked={this.props.locked}
43             moderators={this.props.moderators}
44             admins={this.props.admins}
45             markable={this.props.markable}
46             showContext={this.props.showContext}
47             showCommunity={this.props.showCommunity}
48             enableDownvotes={this.props.enableDownvotes}
49             viewType={this.props.viewType}
50             allLanguages={this.props.allLanguages}
51             siteLanguages={this.props.siteLanguages}
52             hideImages={this.props.hideImages}
53           />
54         ))}
55       </div>
56     );
57   }
58 }