2023-06-21 22:28:24 +00:00
|
|
|
import { myAuthRequired } from "@utils/app";
|
2023-06-14 12:20:40 +00:00
|
|
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
2021-09-28 10:38:59 +00:00
|
|
|
import { T } from "inferno-i18next-dess";
|
|
|
|
import {
|
|
|
|
CommentReportView,
|
|
|
|
CommentView,
|
|
|
|
ResolveCommentReport,
|
|
|
|
} from "lemmy-js-client";
|
2023-05-11 18:32:32 +00:00
|
|
|
import { CommentNodeI, CommentViewType } from "../../interfaces";
|
2023-06-22 00:54:35 +00:00
|
|
|
import { I18NextService } from "../../services";
|
2023-06-14 12:20:40 +00:00
|
|
|
import { Icon, Spinner } from "../common/icon";
|
2021-09-28 10:38:59 +00:00
|
|
|
import { PersonListing } from "../person/person-listing";
|
|
|
|
import { CommentNode } from "./comment-node";
|
|
|
|
|
|
|
|
interface CommentReportProps {
|
|
|
|
report: CommentReportView;
|
2023-06-14 12:20:40 +00:00
|
|
|
onResolveReport(form: ResolveCommentReport): void;
|
2021-09-28 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
interface CommentReportState {
|
|
|
|
loading: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class CommentReport extends Component<
|
|
|
|
CommentReportProps,
|
|
|
|
CommentReportState
|
|
|
|
> {
|
|
|
|
state: CommentReportState = {
|
|
|
|
loading: false,
|
|
|
|
};
|
2021-09-28 10:38:59 +00:00
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
componentWillReceiveProps(
|
|
|
|
nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps>
|
|
|
|
): void {
|
|
|
|
if (this.props != nextProps) {
|
|
|
|
this.setState({ loading: false });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-28 10:38:59 +00:00
|
|
|
render() {
|
2023-06-05 21:31:12 +00:00
|
|
|
const r = this.props.report;
|
|
|
|
const comment = r.comment;
|
2023-06-22 00:54:35 +00:00
|
|
|
const tippyContent = I18NextService.i18n.t(
|
2021-12-30 15:26:45 +00:00
|
|
|
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;
|
|
|
|
|
2023-06-05 21:31:12 +00:00
|
|
|
const comment_view: CommentView = {
|
2021-09-28 10:38:59 +00:00
|
|
|
comment,
|
|
|
|
creator: r.comment_creator,
|
|
|
|
post: r.post,
|
|
|
|
community: r.community,
|
|
|
|
creator_banned_from_community: r.creator_banned_from_community,
|
|
|
|
counts: r.counts,
|
2023-05-11 18:32:32 +00:00
|
|
|
subscribed: "NotSubscribed",
|
2021-09-28 10:38:59 +00:00
|
|
|
saved: false,
|
|
|
|
creator_blocked: false,
|
|
|
|
my_vote: r.my_vote,
|
|
|
|
};
|
|
|
|
|
2023-06-05 21:31:12 +00:00
|
|
|
const node: CommentNodeI = {
|
2021-09-28 10:38:59 +00:00
|
|
|
comment_view,
|
2022-07-30 13:28:08 +00:00
|
|
|
children: [],
|
|
|
|
depth: 0,
|
2021-09-28 10:38:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2023-06-20 18:46:16 +00:00
|
|
|
<div className="comment-report">
|
2021-09-28 10:38:59 +00:00
|
|
|
<CommentNode
|
|
|
|
node={node}
|
2022-07-30 13:28:08 +00:00
|
|
|
viewType={CommentViewType.Flat}
|
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={[]}
|
2022-12-19 15:57:29 +00:00
|
|
|
siteLanguages={[]}
|
2022-11-19 02:02:38 +00:00
|
|
|
hideImages
|
2023-06-14 12:20:40 +00:00
|
|
|
// All of these are unused, since its viewonly
|
|
|
|
finished={new Map()}
|
|
|
|
onSaveComment={() => {}}
|
|
|
|
onBlockPerson={() => {}}
|
|
|
|
onDeleteComment={() => {}}
|
|
|
|
onRemoveComment={() => {}}
|
|
|
|
onCommentVote={() => {}}
|
|
|
|
onCommentReport={() => {}}
|
|
|
|
onDistinguishComment={() => {}}
|
|
|
|
onAddModToCommunity={() => {}}
|
|
|
|
onAddAdmin={() => {}}
|
|
|
|
onTransferCommunity={() => {}}
|
|
|
|
onPurgeComment={() => {}}
|
|
|
|
onPurgePerson={() => {}}
|
|
|
|
onCommentReplyRead={() => {}}
|
|
|
|
onPersonMentionRead={() => {}}
|
|
|
|
onBanPersonFromCommunity={() => {}}
|
|
|
|
onBanPerson={() => {}}
|
|
|
|
onCreateComment={() => Promise.resolve({ state: "empty" })}
|
|
|
|
onEditComment={() => Promise.resolve({ state: "empty" })}
|
2021-09-28 10:38:59 +00:00
|
|
|
/>
|
|
|
|
<div>
|
2023-06-22 00:54:35 +00:00
|
|
|
{I18NextService.i18n.t("reporter")}:{" "}
|
|
|
|
<PersonListing person={r.creator} />
|
2021-09-28 10:38:59 +00:00
|
|
|
</div>
|
|
|
|
<div>
|
2023-06-22 00:54:35 +00:00
|
|
|
{I18NextService.i18n.t("reason")}: {r.comment_report.reason}
|
2021-09-28 10:38:59 +00:00
|
|
|
</div>
|
2023-01-04 16:56:24 +00:00
|
|
|
{r.resolver && (
|
|
|
|
<div>
|
|
|
|
{r.comment_report.resolved ? (
|
|
|
|
<T i18nKey="resolved_by">
|
|
|
|
#
|
|
|
|
<PersonListing person={r.resolver} />
|
|
|
|
</T>
|
|
|
|
) : (
|
|
|
|
<T i18nKey="unresolved_by">
|
|
|
|
#
|
|
|
|
<PersonListing person={r.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
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.loading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<Icon
|
|
|
|
icon="check"
|
|
|
|
classes={`icon-inline ${
|
|
|
|
r.comment_report.resolved ? "text-success" : "text-danger"
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
)}
|
2021-09-28 10:38:59 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleResolveReport(i: CommentReport) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ loading: true });
|
|
|
|
i.props.onResolveReport({
|
|
|
|
report_id: i.props.report.comment_report.id,
|
|
|
|
resolved: !i.props.report.comment_report.resolved,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2021-09-28 10:38:59 +00:00
|
|
|
}
|
|
|
|
}
|