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 { mdToHtml } from "../../markdown";
9 import { I18NextService } from "../../services";
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 = I18NextService.i18n.t(
43 r.private_message_report.resolved ? "unresolve_report" : "resolve_report",
47 <div className="private-message-report">
49 {I18NextService.i18n.t("creator")}:{" "}
50 <PersonListing person={r.private_message_creator} />
53 {I18NextService.i18n.t("message")}:
56 dangerouslySetInnerHTML={mdToHtml(pmr.original_pm_text)}
60 {I18NextService.i18n.t("reporter")}:{" "}
61 <PersonListing person={r.creator} />
64 {I18NextService.i18n.t("reason")}: {pmr.reason}
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}
87 {this.state.loading ? (
92 classes={`icon-inline ${
93 pmr.resolved ? "text-success" : "text-danger"
102 handleResolveReport(i: PrivateMessageReport) {
103 i.setState({ loading: true });
104 const pmr = i.props.report.private_message_report;
105 i.props.onResolveReport({
107 resolved: !pmr.resolved,
108 auth: myAuthRequired(),