]> Untitled Git - lemmy-ui.git/blob - src/shared/components/comment/comment-nodes.tsx
Adding Community Language fixes. #783 (#868)
[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   siteLanguages: number[];
28   hideImages?: boolean;
29 }
30
31 export class CommentNodes extends Component<CommentNodesProps, any> {
32   constructor(props: any, context: any) {
33     super(props, context);
34   }
35
36   render() {
37     let maxComments = this.props.maxCommentsShown.unwrapOr(
38       this.props.nodes.length
39     );
40
41     return (
42       <div className="comments">
43         {this.props.nodes.slice(0, maxComments).map(node => (
44           <CommentNode
45             key={node.comment_view.comment.id}
46             node={node}
47             noBorder={this.props.noBorder}
48             noIndent={this.props.noIndent}
49             viewOnly={this.props.viewOnly}
50             locked={this.props.locked}
51             moderators={this.props.moderators}
52             admins={this.props.admins}
53             markable={this.props.markable}
54             showContext={this.props.showContext}
55             showCommunity={this.props.showCommunity}
56             enableDownvotes={this.props.enableDownvotes}
57             viewType={this.props.viewType}
58             allLanguages={this.props.allLanguages}
59             siteLanguages={this.props.siteLanguages}
60             hideImages={this.props.hideImages}
61           />
62         ))}
63       </div>
64     );
65   }
66 }