1 import classNames from "classnames";
2 import { Component } from "inferno";
3 import { CommunityModeratorView, Language, PersonView } from "lemmy-js-client";
4 import { CommentNodeI, CommentViewType } from "../../interfaces";
5 import { colorList } from "../../utils";
6 import { CommentNode } from "./comment-node";
8 interface CommentNodesProps {
10 moderators?: CommunityModeratorView[];
11 admins?: PersonView[];
12 maxCommentsShown?: number;
18 showContext?: boolean;
19 showCommunity?: boolean;
20 enableDownvotes?: boolean;
21 viewType: CommentViewType;
22 allLanguages: Language[];
23 siteLanguages: number[];
29 export class CommentNodes extends Component<CommentNodesProps, any> {
30 constructor(props: CommentNodesProps, context: any) {
31 super(props, context);
35 const maxComments = this.props.maxCommentsShown ?? this.props.nodes.length;
37 const borderColor = this.props.depth
38 ? colorList[this.props.depth % colorList.length]
41 return this.props.nodes.length > 0 ? (
43 className={classNames("comments", {
44 "ms-2": !!this.props.isChild,
45 "border-top border-light": !this.props.noBorder,
48 "border-left-color": borderColor,
49 "border-left-style": "solid",
50 "border-left-width": `2px`,
53 {this.props.nodes.slice(0, maxComments).map(node => (
55 key={node.comment_view.comment.id}
57 noBorder={this.props.noBorder}
58 noIndent={this.props.noIndent}
59 viewOnly={this.props.viewOnly}
60 locked={this.props.locked}
61 moderators={this.props.moderators}
62 admins={this.props.admins}
63 markable={this.props.markable}
64 showContext={this.props.showContext}
65 showCommunity={this.props.showCommunity}
66 enableDownvotes={this.props.enableDownvotes}
67 viewType={this.props.viewType}
68 allLanguages={this.props.allLanguages}
69 siteLanguages={this.props.siteLanguages}
70 hideImages={this.props.hideImages}