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-1": !!this.props.isChild,
45 "border-top border-light": !this.props.noBorder,
47 style={`border-left: 2px solid ${borderColor} !important;`}
49 {this.props.nodes.slice(0, maxComments).map(node => (
51 key={node.comment_view.comment.id}
53 noBorder={this.props.noBorder}
54 noIndent={this.props.noIndent}
55 viewOnly={this.props.viewOnly}
56 locked={this.props.locked}
57 moderators={this.props.moderators}
58 admins={this.props.admins}
59 markable={this.props.markable}
60 showContext={this.props.showContext}
61 showCommunity={this.props.showCommunity}
62 enableDownvotes={this.props.enableDownvotes}
63 viewType={this.props.viewType}
64 allLanguages={this.props.allLanguages}
65 siteLanguages={this.props.siteLanguages}
66 hideImages={this.props.hideImages}