1 import { myAuthRequired } from "@utils/app";
2 import { Component, InfernoNode, linkEvent } from "inferno";
3 import { T } from "inferno-i18next-dess";
8 } from "lemmy-js-client";
9 import { CommentNodeI, CommentViewType } from "../../interfaces";
10 import { I18NextService } from "../../services";
11 import { Icon, Spinner } from "../common/icon";
12 import { PersonListing } from "../person/person-listing";
13 import { CommentNode } from "./comment-node";
15 interface CommentReportProps {
16 report: CommentReportView;
17 onResolveReport(form: ResolveCommentReport): void;
20 interface CommentReportState {
24 export class CommentReport extends Component<
28 state: CommentReportState = {
31 constructor(props: any, context: any) {
32 super(props, context);
35 componentWillReceiveProps(
36 nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps>,
38 if (this.props !== nextProps) {
39 this.setState({ loading: false });
44 const r = this.props.report;
45 const comment = r.comment;
46 const tippyContent = I18NextService.i18n.t(
47 r.comment_report.resolved ? "unresolve_report" : "resolve_report",
50 // Set the original post data ( a troll could change it )
51 comment.content = r.comment_report.original_comment_text;
53 const comment_view: CommentView = {
55 creator: r.comment_creator,
57 community: r.community,
58 creator_banned_from_community: r.creator_banned_from_community,
60 subscribed: "NotSubscribed",
62 creator_blocked: false,
66 const node: CommentNodeI = {
73 <div className="comment-report">
76 viewType={CommentViewType.Flat}
77 enableDownvotes={true}
83 // All of these are unused, since its viewonly
85 onSaveComment={() => {}}
86 onBlockPerson={() => {}}
87 onDeleteComment={() => {}}
88 onRemoveComment={() => {}}
89 onCommentVote={() => {}}
90 onCommentReport={() => {}}
91 onDistinguishComment={() => {}}
92 onAddModToCommunity={() => {}}
94 onTransferCommunity={() => {}}
95 onPurgeComment={() => {}}
96 onPurgePerson={() => {}}
97 onCommentReplyRead={() => {}}
98 onPersonMentionRead={() => {}}
99 onBanPersonFromCommunity={() => {}}
100 onBanPerson={() => {}}
101 onCreateComment={() => Promise.resolve({ state: "empty" })}
102 onEditComment={() => Promise.resolve({ state: "empty" })}
105 {I18NextService.i18n.t("reporter")}:{" "}
106 <PersonListing person={r.creator} />
109 {I18NextService.i18n.t("reason")}: {r.comment_report.reason}
113 {r.comment_report.resolved ? (
114 <T i18nKey="resolved_by">
116 <PersonListing person={r.resolver} />
119 <T i18nKey="unresolved_by">
121 <PersonListing person={r.resolver} />
127 className="btn btn-link btn-animate text-muted py-0"
128 onClick={linkEvent(this, this.handleResolveReport)}
129 data-tippy-content={tippyContent}
130 aria-label={tippyContent}
132 {this.state.loading ? (
137 classes={`icon-inline ${
138 r.comment_report.resolved ? "text-success" : "text-danger"
147 handleResolveReport(i: CommentReport) {
148 i.setState({ loading: true });
149 i.props.onResolveReport({
150 report_id: i.props.report.comment_report.id,
151 resolved: !i.props.report.comment_report.resolved,
152 auth: myAuthRequired(),