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