1 import { Component, linkEvent } from "inferno";
2 import { T } from "inferno-i18next-dess";
4 CommentNode as CommentNodeI,
9 } from "lemmy-js-client";
10 import { i18n } from "../../i18next";
11 import { CommentViewType } from "../../interfaces";
12 import { WebSocketService } from "../../services";
13 import { myAuth, wsClient } from "../../utils";
14 import { Icon } from "../common/icon";
15 import { PersonListing } from "../person/person-listing";
16 import { CommentNode } from "./comment-node";
18 interface CommentReportProps {
19 report: CommentReportView;
22 export class CommentReport extends Component<CommentReportProps, any> {
23 constructor(props: any, context: any) {
24 super(props, context);
28 let r = this.props.report;
29 let comment = r.comment;
30 let tippyContent = i18n.t(
31 r.comment_report.resolved ? "unresolve_report" : "resolve_report"
34 // Set the original post data ( a troll could change it )
35 comment.content = r.comment_report.original_comment_text;
37 let comment_view: CommentView = {
39 creator: r.comment_creator,
41 community: r.community,
42 creator_banned_from_community: r.creator_banned_from_community,
44 subscribed: SubscribedType.NotSubscribed,
46 creator_blocked: false,
50 let node: CommentNodeI = {
60 viewType={CommentViewType.Flat}
61 enableDownvotes={true}
69 {i18n.t("reporter")}: <PersonListing person={r.creator} />
72 {i18n.t("reason")}: {r.comment_report.reason}
76 {r.comment_report.resolved ? (
77 <T i18nKey="resolved_by">
79 <PersonListing person={r.resolver} />
82 <T i18nKey="unresolved_by">
84 <PersonListing person={r.resolver} />
90 className="btn btn-link btn-animate text-muted py-0"
91 onClick={linkEvent(this, this.handleResolveReport)}
92 data-tippy-content={tippyContent}
93 aria-label={tippyContent}
97 classes={`icon-inline ${
98 r.comment_report.resolved ? "text-success" : "text-danger"
106 handleResolveReport(i: CommentReport) {
109 let form: ResolveCommentReport = {
110 report_id: i.props.report.comment_report.id,
111 resolved: !i.props.report.comment_report.resolved,
114 WebSocketService.Instance.send(wsClient.resolveCommentReport(form));