2023-06-14 12:20:40 +00:00
|
|
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
2022-09-28 12:50:47 +00:00
|
|
|
import { T } from "inferno-i18next-dess";
|
|
|
|
import {
|
|
|
|
PrivateMessageReportView,
|
|
|
|
ResolvePrivateMessageReport,
|
|
|
|
} from "lemmy-js-client";
|
|
|
|
import { i18n } from "../../i18next";
|
2023-06-14 12:20:40 +00:00
|
|
|
import { mdToHtml, myAuthRequired } from "../../utils";
|
|
|
|
import { Icon, Spinner } from "../common/icon";
|
2022-09-28 12:50:47 +00:00
|
|
|
import { PersonListing } from "../person/person-listing";
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
report: PrivateMessageReportView;
|
2023-06-14 12:20:40 +00:00
|
|
|
onResolveReport(form: ResolvePrivateMessageReport): void;
|
2022-09-28 12:50:47 +00:00
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
interface State {
|
|
|
|
loading: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class PrivateMessageReport extends Component<Props, State> {
|
|
|
|
state: State = {
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
|
2022-09-28 12:50:47 +00:00
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
componentWillReceiveProps(
|
|
|
|
nextProps: Readonly<{ children?: InfernoNode } & Props>
|
|
|
|
): void {
|
|
|
|
if (this.props != nextProps) {
|
|
|
|
this.setState({ loading: false });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-28 12:50:47 +00:00
|
|
|
render() {
|
2023-06-05 21:31:12 +00:00
|
|
|
const r = this.props.report;
|
|
|
|
const pmr = r.private_message_report;
|
|
|
|
const tippyContent = i18n.t(
|
2022-09-28 12:50:47 +00:00
|
|
|
r.private_message_report.resolved ? "unresolve_report" : "resolve_report"
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
{i18n.t("creator")}:{" "}
|
|
|
|
<PersonListing person={r.private_message_creator} />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{i18n.t("message")}:
|
|
|
|
<div
|
|
|
|
className="md-div"
|
|
|
|
dangerouslySetInnerHTML={mdToHtml(pmr.original_pm_text)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{i18n.t("reporter")}: <PersonListing person={r.creator} />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{i18n.t("reason")}: {pmr.reason}
|
|
|
|
</div>
|
2023-01-04 16:56:24 +00:00
|
|
|
{r.resolver && (
|
|
|
|
<div>
|
|
|
|
{pmr.resolved ? (
|
|
|
|
<T i18nKey="resolved_by">
|
|
|
|
#
|
|
|
|
<PersonListing person={r.resolver} />
|
|
|
|
</T>
|
|
|
|
) : (
|
|
|
|
<T i18nKey="unresolved_by">
|
|
|
|
#
|
|
|
|
<PersonListing person={r.resolver} />
|
|
|
|
</T>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
2022-09-28 12:50:47 +00:00
|
|
|
<button
|
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
|
|
|
onClick={linkEvent(this, this.handleResolveReport)}
|
|
|
|
data-tippy-content={tippyContent}
|
|
|
|
aria-label={tippyContent}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.loading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<Icon
|
|
|
|
icon="check"
|
|
|
|
classes={`icon-inline ${
|
|
|
|
pmr.resolved ? "text-success" : "text-danger"
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
)}
|
2022-09-28 12:50:47 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleResolveReport(i: PrivateMessageReport) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ loading: true });
|
2023-06-05 21:31:12 +00:00
|
|
|
const pmr = i.props.report.private_message_report;
|
2023-06-14 12:20:40 +00:00
|
|
|
i.props.onResolveReport({
|
|
|
|
report_id: pmr.id,
|
|
|
|
resolved: !pmr.resolved,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2022-09-28 12:50:47 +00:00
|
|
|
}
|
|
|
|
}
|