1 import { None } from "@sniptt/monads";
2 import { Component, linkEvent } from "inferno";
3 import { T } from "inferno-i18next-dess";
8 } from "lemmy-js-client";
9 import { i18n } from "../../i18next";
10 import { CommentNode as CommentNodeI } from "../../interfaces";
11 import { WebSocketService } from "../../services";
12 import { auth, wsClient } from "../../utils";
13 import { Icon } from "../common/icon";
14 import { PersonListing } from "../person/person-listing";
15 import { CommentNode } from "./comment-node";
17 interface CommentReportProps {
18 report: CommentReportView;
21 export class CommentReport extends Component<CommentReportProps, any> {
22 constructor(props: any, context: any) {
23 super(props, context);
27 let r = this.props.report;
28 let comment = r.comment;
29 let tippyContent = i18n.t(
30 r.comment_report.resolved ? "unresolve_report" : "resolve_report"
33 // Set the original post data ( a troll could change it )
34 comment.content = r.comment_report.original_comment_text;
36 let comment_view: CommentView = {
38 creator: r.comment_creator,
40 community: r.community,
41 creator_banned_from_community: r.creator_banned_from_community,
45 creator_blocked: false,
50 let node: CommentNodeI = {
60 enableDownvotes={true}
65 {i18n.t("reporter")}: <PersonListing person={r.creator} />
68 {i18n.t("reason")}: {r.comment_report.reason}
73 {r.comment_report.resolved ? (
74 <T i18nKey="resolved_by">
76 <PersonListing person={resolver} />
79 <T i18nKey="unresolved_by">
81 <PersonListing person={resolver} />
89 className="btn btn-link btn-animate text-muted py-0"
90 onClick={linkEvent(this, this.handleResolveReport)}
91 data-tippy-content={tippyContent}
92 aria-label={tippyContent}
96 classes={`icon-inline ${
97 r.comment_report.resolved ? "text-success" : "text-danger"
105 handleResolveReport(i: CommentReport) {
106 let form = new ResolveCommentReport({
107 report_id: i.props.report.comment_report.id,
108 resolved: !i.props.report.comment_report.resolved,
109 auth: auth().unwrap(),
111 WebSocketService.Instance.send(wsClient.resolveCommentReport(form));