1 import { Component, linkEvent } from "inferno";
2 import { T } from "inferno-i18next-dess";
7 } from "lemmy-js-client";
8 import { i18n } from "../../i18next";
9 import { CommentNode as CommentNodeI } from "../../interfaces";
10 import { WebSocketService } from "../../services";
11 import { authField, wsClient } from "../../utils";
12 import { Icon } from "../common/icon";
13 import { PersonListing } from "../person/person-listing";
14 import { CommentNode } from "./comment-node";
16 interface CommentReportProps {
17 report: CommentReportView;
20 export class CommentReport extends Component<CommentReportProps, any> {
21 constructor(props: any, context: any) {
22 super(props, context);
26 let r = this.props.report;
27 let comment = r.comment;
28 let tippyContent = i18n.t(
29 r.comment_report.resolved ? "unresolve_report" : "resolve_report"
32 // Set the original post data ( a troll could change it )
33 comment.content = r.comment_report.original_comment_text;
35 let comment_view: CommentView = {
37 creator: r.comment_creator,
39 community: r.community,
40 creator_banned_from_community: r.creator_banned_from_community,
44 creator_blocked: false,
48 let node: CommentNodeI = {
58 enableDownvotes={true}
63 {i18n.t("reporter")}: <PersonListing person={r.creator} />
66 {i18n.t("reason")}: {r.comment_report.reason}
70 {r.comment_report.resolved ? (
71 <T i18nKey="resolved_by">
73 <PersonListing person={r.resolver} />
76 <T i18nKey="unresolved_by">
78 <PersonListing person={r.resolver} />
84 className="btn btn-link btn-animate text-muted py-0"
85 onClick={linkEvent(this, this.handleResolveReport)}
86 data-tippy-content={tippyContent}
87 aria-label={tippyContent}
91 classes={`icon-inline ${
92 r.comment_report.resolved ? "text-success" : "text-danger"
100 handleResolveReport(i: CommentReport) {
101 let form: ResolveCommentReport = {
102 report_id: i.props.report.comment_report.id,
103 resolved: !i.props.report.comment_report.resolved,
106 WebSocketService.Instance.send(wsClient.resolveCommentReport(form));