2021-09-28 10:38:59 +00:00
|
|
|
import { Component, linkEvent } from "inferno";
|
|
|
|
import { T } from "inferno-i18next-dess";
|
2022-06-23 13:35:53 +00:00
|
|
|
import {
|
|
|
|
PostReportView,
|
|
|
|
PostView,
|
|
|
|
ResolvePostReport,
|
|
|
|
SubscribedType,
|
|
|
|
} from "lemmy-js-client";
|
2021-09-28 10:38:59 +00:00
|
|
|
import { i18n } from "../../i18next";
|
|
|
|
import { WebSocketService } from "../../services";
|
2023-01-04 16:56:24 +00:00
|
|
|
import { myAuth, wsClient } from "../../utils";
|
2021-09-28 10:38:59 +00:00
|
|
|
import { Icon } from "../common/icon";
|
|
|
|
import { PersonListing } from "../person/person-listing";
|
|
|
|
import { PostListing } from "./post-listing";
|
|
|
|
|
|
|
|
interface PostReportProps {
|
|
|
|
report: PostReportView;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class PostReport extends Component<PostReportProps, any> {
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let r = this.props.report;
|
2023-01-04 16:56:24 +00:00
|
|
|
let resolver = r.resolver;
|
2021-09-28 10:38:59 +00:00
|
|
|
let post = r.post;
|
2021-12-30 15:26:45 +00:00
|
|
|
let tippyContent = i18n.t(
|
|
|
|
r.post_report.resolved ? "unresolve_report" : "resolve_report"
|
|
|
|
);
|
2021-09-28 10:38:59 +00:00
|
|
|
|
|
|
|
// Set the original post data ( a troll could change it )
|
|
|
|
post.name = r.post_report.original_post_name;
|
|
|
|
post.url = r.post_report.original_post_url;
|
|
|
|
post.body = r.post_report.original_post_body;
|
|
|
|
let pv: PostView = {
|
|
|
|
post,
|
|
|
|
creator: r.post_creator,
|
|
|
|
community: r.community,
|
|
|
|
creator_banned_from_community: r.creator_banned_from_community,
|
|
|
|
counts: r.counts,
|
2022-06-23 13:35:53 +00:00
|
|
|
subscribed: SubscribedType.NotSubscribed,
|
2021-09-28 10:38:59 +00:00
|
|
|
saved: false,
|
|
|
|
read: false,
|
|
|
|
creator_blocked: false,
|
|
|
|
my_vote: r.my_vote,
|
2022-09-27 19:42:24 +00:00
|
|
|
unread_comments: 0,
|
2021-09-28 10:38:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<PostListing
|
|
|
|
post_view={pv}
|
|
|
|
showCommunity={true}
|
|
|
|
enableDownvotes={true}
|
|
|
|
enableNsfw={true}
|
2022-02-02 14:56:43 +00:00
|
|
|
viewOnly={true}
|
2022-09-22 15:14:58 +00:00
|
|
|
allLanguages={[]}
|
2022-12-19 15:57:29 +00:00
|
|
|
siteLanguages={[]}
|
2022-11-18 02:11:30 +00:00
|
|
|
hideImage
|
2021-09-28 10:38:59 +00:00
|
|
|
/>
|
|
|
|
<div>
|
|
|
|
{i18n.t("reporter")}: <PersonListing person={r.creator} />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{i18n.t("reason")}: {r.post_report.reason}
|
|
|
|
</div>
|
2023-01-04 16:56:24 +00:00
|
|
|
{resolver && (
|
|
|
|
<div>
|
|
|
|
{r.post_report.resolved ? (
|
|
|
|
<T i18nKey="resolved_by">
|
|
|
|
#
|
|
|
|
<PersonListing person={resolver} />
|
|
|
|
</T>
|
|
|
|
) : (
|
|
|
|
<T i18nKey="unresolved_by">
|
|
|
|
#
|
|
|
|
<PersonListing person={resolver} />
|
|
|
|
</T>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
2021-09-28 10:38:59 +00:00
|
|
|
<button
|
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
|
|
|
onClick={linkEvent(this, this.handleResolveReport)}
|
2021-12-30 15:26:45 +00:00
|
|
|
data-tippy-content={tippyContent}
|
|
|
|
aria-label={tippyContent}
|
2021-09-28 10:38:59 +00:00
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
icon="check"
|
|
|
|
classes={`icon-inline ${
|
|
|
|
r.post_report.resolved ? "text-success" : "text-danger"
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleResolveReport(i: PostReport) {
|
2023-01-04 16:56:24 +00:00
|
|
|
let auth = myAuth();
|
|
|
|
if (auth) {
|
|
|
|
let form: ResolvePostReport = {
|
|
|
|
report_id: i.props.report.post_report.id,
|
|
|
|
resolved: !i.props.report.post_report.resolved,
|
|
|
|
auth,
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.send(wsClient.resolvePostReport(form));
|
|
|
|
}
|
2021-09-28 10:38:59 +00:00
|
|
|
}
|
|
|
|
}
|