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 { CommentNodeI, CommentViewType } from "../../interfaces";
10 import { WebSocketService } from "../../services";
11 import { myAuth, 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,
42 subscribed: "NotSubscribed",
44 creator_blocked: false,
48 let node: CommentNodeI = {
58 viewType={CommentViewType.Flat}
59 enableDownvotes={true}
67 {i18n.t("reporter")}: <PersonListing person={r.creator} />
70 {i18n.t("reason")}: {r.comment_report.reason}
74 {r.comment_report.resolved ? (
75 <T i18nKey="resolved_by">
77 <PersonListing person={r.resolver} />
80 <T i18nKey="unresolved_by">
82 <PersonListing person={r.resolver} />
88 className="btn btn-link btn-animate text-muted py-0"
89 onClick={linkEvent(this, this.handleResolveReport)}
90 data-tippy-content={tippyContent}
91 aria-label={tippyContent}
95 classes={`icon-inline ${
96 r.comment_report.resolved ? "text-success" : "text-danger"
104 handleResolveReport(i: CommentReport) {
107 let form: ResolveCommentReport = {
108 report_id: i.props.report.comment_report.id,
109 resolved: !i.props.report.comment_report.resolved,
112 WebSocketService.Instance.send(wsClient.resolveCommentReport(form));