2022-06-21 21:42:29 +00:00
|
|
|
import { None } from "@sniptt/monads";
|
2021-09-28 10:38:59 +00:00
|
|
|
import { Component, linkEvent } from "inferno";
|
|
|
|
import { T } from "inferno-i18next-dess";
|
|
|
|
import {
|
2022-07-30 13:28:08 +00:00
|
|
|
CommentNode as CommentNodeI,
|
2021-09-28 10:38:59 +00:00
|
|
|
CommentReportView,
|
|
|
|
CommentView,
|
|
|
|
ResolveCommentReport,
|
2022-06-23 13:35:53 +00:00
|
|
|
SubscribedType,
|
2021-09-28 10:38:59 +00:00
|
|
|
} from "lemmy-js-client";
|
|
|
|
import { i18n } from "../../i18next";
|
2022-07-30 13:28:08 +00:00
|
|
|
import { CommentViewType } from "../../interfaces";
|
2021-09-28 10:38:59 +00:00
|
|
|
import { WebSocketService } from "../../services";
|
2022-06-21 21:42:29 +00:00
|
|
|
import { auth, wsClient } from "../../utils";
|
2021-09-28 10:38:59 +00:00
|
|
|
import { Icon } from "../common/icon";
|
|
|
|
import { PersonListing } from "../person/person-listing";
|
|
|
|
import { CommentNode } from "./comment-node";
|
|
|
|
|
|
|
|
interface CommentReportProps {
|
|
|
|
report: CommentReportView;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class CommentReport extends Component<CommentReportProps, any> {
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let r = this.props.report;
|
|
|
|
let comment = r.comment;
|
2021-12-30 15:26:45 +00:00
|
|
|
let tippyContent = i18n.t(
|
|
|
|
r.comment_report.resolved ? "unresolve_report" : "resolve_report"
|
|
|
|
);
|
2021-09-28 10:38:59 +00:00
|
|
|
|
|
|
|
// Set the original post data ( a troll could change it )
|
|
|
|
comment.content = r.comment_report.original_comment_text;
|
|
|
|
|
|
|
|
let comment_view: CommentView = {
|
|
|
|
comment,
|
|
|
|
creator: r.comment_creator,
|
|
|
|
post: r.post,
|
|
|
|
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,
|
|
|
|
creator_blocked: false,
|
|
|
|
my_vote: r.my_vote,
|
|
|
|
};
|
|
|
|
|
|
|
|
let node: CommentNodeI = {
|
|
|
|
comment_view,
|
2022-07-30 13:28:08 +00:00
|
|
|
children: [],
|
|
|
|
depth: 0,
|
2021-09-28 10:38:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<CommentNode
|
|
|
|
node={node}
|
2022-07-30 13:28:08 +00:00
|
|
|
viewType={CommentViewType.Flat}
|
2022-06-21 21:42:29 +00:00
|
|
|
moderators={None}
|
|
|
|
admins={None}
|
2021-09-28 10:38:59 +00:00
|
|
|
enableDownvotes={true}
|
2022-02-02 14:56:43 +00:00
|
|
|
viewOnly={true}
|
|
|
|
showCommunity={true}
|
2022-09-22 15:14:58 +00:00
|
|
|
allLanguages={[]}
|
2021-09-28 10:38:59 +00:00
|
|
|
/>
|
|
|
|
<div>
|
|
|
|
{i18n.t("reporter")}: <PersonListing person={r.creator} />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{i18n.t("reason")}: {r.comment_report.reason}
|
|
|
|
</div>
|
2022-06-21 21:42:29 +00:00
|
|
|
{r.resolver.match({
|
|
|
|
some: resolver => (
|
|
|
|
<div>
|
|
|
|
{r.comment_report.resolved ? (
|
|
|
|
<T i18nKey="resolved_by">
|
|
|
|
#
|
|
|
|
<PersonListing person={resolver} />
|
|
|
|
</T>
|
|
|
|
) : (
|
|
|
|
<T i18nKey="unresolved_by">
|
|
|
|
#
|
|
|
|
<PersonListing person={resolver} />
|
|
|
|
</T>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
none: <></>,
|
|
|
|
})}
|
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.comment_report.resolved ? "text-success" : "text-danger"
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleResolveReport(i: CommentReport) {
|
2022-06-21 21:42:29 +00:00
|
|
|
let form = new ResolveCommentReport({
|
2021-09-28 10:38:59 +00:00
|
|
|
report_id: i.props.report.comment_report.id,
|
|
|
|
resolved: !i.props.report.comment_report.resolved,
|
2022-06-21 21:42:29 +00:00
|
|
|
auth: auth().unwrap(),
|
|
|
|
});
|
2021-09-28 10:38:59 +00:00
|
|
|
WebSocketService.Instance.send(wsClient.resolveCommentReport(form));
|
|
|
|
}
|
|
|
|
}
|