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}
61 {i18n.t("reporter")}: <PersonListing person={r.creator} />
64 {i18n.t("reason")}: {r.comment_report.reason}
68 {r.comment_report.resolved ? (
69 <T i18nKey="resolved_by">
71 <PersonListing person={r.resolver} />
74 <T i18nKey="unresolved_by">
76 <PersonListing person={r.resolver} />
82 className="btn btn-link btn-animate text-muted py-0"
83 onClick={linkEvent(this, this.handleResolveReport)}
84 data-tippy-content={tippyContent}
85 aria-label={tippyContent}
89 classes={`icon-inline ${
90 r.comment_report.resolved ? "text-success" : "text-danger"
98 handleResolveReport(i: CommentReport) {
99 let form: ResolveCommentReport = {
100 report_id: i.props.report.comment_report.id,
101 resolved: !i.props.report.comment_report.resolved,
104 WebSocketService.Instance.send(wsClient.resolveCommentReport(form));