1 import { myAuthRequired } from "@utils/app";
2 import { Component, InfernoNode, linkEvent } from "inferno";
3 import { T } from "inferno-i18next-dess";
5 PrivateMessageReportView,
6 ResolvePrivateMessageReport,
7 } from "lemmy-js-client";
8 import { i18n } from "../../i18next";
9 import { mdToHtml } from "../../markdown";
10 import { Icon, Spinner } from "../common/icon";
11 import { PersonListing } from "../person/person-listing";
14 report: PrivateMessageReportView;
15 onResolveReport(form: ResolvePrivateMessageReport): void;
22 export class PrivateMessageReport extends Component<Props, State> {
27 constructor(props: any, context: any) {
28 super(props, context);
31 componentWillReceiveProps(
32 nextProps: Readonly<{ children?: InfernoNode } & Props>
34 if (this.props != nextProps) {
35 this.setState({ loading: false });
40 const r = this.props.report;
41 const pmr = r.private_message_report;
42 const tippyContent = i18n.t(
43 r.private_message_report.resolved ? "unresolve_report" : "resolve_report"
47 <div className="private-message-report">
49 {i18n.t("creator")}:{" "}
50 <PersonListing person={r.private_message_creator} />
56 dangerouslySetInnerHTML={mdToHtml(pmr.original_pm_text)}
60 {i18n.t("reporter")}: <PersonListing person={r.creator} />
63 {i18n.t("reason")}: {pmr.reason}
68 <T i18nKey="resolved_by">
70 <PersonListing person={r.resolver} />
73 <T i18nKey="unresolved_by">
75 <PersonListing person={r.resolver} />
81 className="btn btn-link btn-animate text-muted py-0"
82 onClick={linkEvent(this, this.handleResolveReport)}
83 data-tippy-content={tippyContent}
84 aria-label={tippyContent}
86 {this.state.loading ? (
91 classes={`icon-inline ${
92 pmr.resolved ? "text-success" : "text-danger"
101 handleResolveReport(i: PrivateMessageReport) {
102 i.setState({ loading: true });
103 const pmr = i.props.report.private_message_report;
104 i.props.onResolveReport({
106 resolved: !pmr.resolved,
107 auth: myAuthRequired(),