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