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