1 import { Component, linkEvent } from "inferno";
6 BanFromCommunityResponse,
13 CommentReportResponse,
21 CreatePrivateMessageReport,
28 GetPersonMentionsResponse,
33 MarkCommentReplyAsRead,
34 MarkPersonMentionAsRead,
35 MarkPrivateMessageAsRead,
36 PersonMentionResponse,
38 PrivateMessageReportResponse,
39 PrivateMessageResponse,
41 PrivateMessagesResponse,
49 } from "lemmy-js-client";
50 import { i18n } from "../../i18next";
51 import { CommentViewType, InitialFetchRequest } from "../../interfaces";
52 import { UserService } from "../../services";
53 import { FirstLoadService } from "../../services/FirstLoadService";
54 import { HttpService, RequestState } from "../../services/HttpService";
71 import { CommentNodes } from "../comment/comment-nodes";
72 import { CommentSortSelect } from "../common/comment-sort-select";
73 import { HtmlTags } from "../common/html-tags";
74 import { Icon, Spinner } from "../common/icon";
75 import { Paginator } from "../common/paginator";
76 import { PrivateMessage } from "../private_message/private-message";
98 view: CommentView | PrivateMessageView | PersonMentionView | CommentReplyView;
102 interface InboxState {
103 unreadOrAll: UnreadOrAll;
104 messageType: MessageType;
105 repliesRes: RequestState<GetRepliesResponse>;
106 mentionsRes: RequestState<GetPersonMentionsResponse>;
107 messagesRes: RequestState<PrivateMessagesResponse>;
108 markAllAsReadRes: RequestState<GetRepliesResponse>;
109 sort: CommentSortType;
111 siteRes: GetSiteResponse;
112 finished: Map<CommentId, boolean | undefined>;
113 isIsomorphic: boolean;
116 export class Inbox extends Component<any, InboxState> {
117 private isoData = setIsoData(this.context);
118 state: InboxState = {
119 unreadOrAll: UnreadOrAll.Unread,
120 messageType: MessageType.All,
123 siteRes: this.isoData.site_res,
124 repliesRes: { state: "empty" },
125 mentionsRes: { state: "empty" },
126 messagesRes: { state: "empty" },
127 markAllAsReadRes: { state: "empty" },
132 constructor(props: any, context: any) {
133 super(props, context);
135 this.handleSortChange = this.handleSortChange.bind(this);
136 this.handlePageChange = this.handlePageChange.bind(this);
138 this.handleCreateComment = this.handleCreateComment.bind(this);
139 this.handleEditComment = this.handleEditComment.bind(this);
140 this.handleSaveComment = this.handleSaveComment.bind(this);
141 this.handleBlockPerson = this.handleBlockPerson.bind(this);
142 this.handleDeleteComment = this.handleDeleteComment.bind(this);
143 this.handleRemoveComment = this.handleRemoveComment.bind(this);
144 this.handleCommentVote = this.handleCommentVote.bind(this);
145 this.handleAddModToCommunity = this.handleAddModToCommunity.bind(this);
146 this.handleAddAdmin = this.handleAddAdmin.bind(this);
147 this.handlePurgePerson = this.handlePurgePerson.bind(this);
148 this.handlePurgeComment = this.handlePurgeComment.bind(this);
149 this.handleCommentReport = this.handleCommentReport.bind(this);
150 this.handleDistinguishComment = this.handleDistinguishComment.bind(this);
151 this.handleTransferCommunity = this.handleTransferCommunity.bind(this);
152 this.handleCommentReplyRead = this.handleCommentReplyRead.bind(this);
153 this.handlePersonMentionRead = this.handlePersonMentionRead.bind(this);
154 this.handleBanFromCommunity = this.handleBanFromCommunity.bind(this);
155 this.handleBanPerson = this.handleBanPerson.bind(this);
157 this.handleDeleteMessage = this.handleDeleteMessage.bind(this);
158 this.handleMarkMessageAsRead = this.handleMarkMessageAsRead.bind(this);
159 this.handleMessageReport = this.handleMessageReport.bind(this);
160 this.handleCreateMessage = this.handleCreateMessage.bind(this);
161 this.handleEditMessage = this.handleEditMessage.bind(this);
163 // Only fetch the data if coming from another route
164 if (FirstLoadService.isFirstLoad) {
165 const [repliesRes, mentionsRes, messagesRes] = this.isoData.routeData;
177 async componentDidMount() {
178 if (!this.state.isIsomorphic) {
179 await this.refetch();
183 get documentTitle(): string {
184 const mui = UserService.Instance.myUserInfo;
186 ? `@${mui.local_user_view.person.name} ${i18n.t("inbox")} - ${
187 this.state.siteRes.site_view.site.name
192 get hasUnreads(): boolean {
193 if (this.state.unreadOrAll == UnreadOrAll.Unread) {
194 const { repliesRes, mentionsRes, messagesRes } = this.state;
196 repliesRes.state == "success" ? repliesRes.data.replies.length : 0;
198 mentionsRes.state == "success" ? mentionsRes.data.mentions.length : 0;
200 messagesRes.state == "success"
201 ? messagesRes.data.private_messages.length
204 return replyCount + mentionCount + messageCount > 0;
211 const auth = myAuth();
212 const inboxRss = auth ? `/feeds/inbox/${auth}.xml` : undefined;
214 <div className="container-lg">
215 <div className="row">
216 <div className="col-12">
218 title={this.documentTitle}
219 path={this.context.router.route.match.url}
221 <h5 className="mb-2">
225 <a href={inboxRss} title="RSS" rel={relTags}>
226 <Icon icon="rss" classes="ml-2 text-muted small" />
230 type="application/atom+xml"
236 {this.hasUnreads && (
238 className="btn btn-secondary mb-2"
239 onClick={linkEvent(this, this.handleMarkAllAsRead)}
241 {this.state.markAllAsReadRes.state == "loading" ? (
244 i18n.t("mark_all_as_read")
251 page={this.state.page}
252 onChange={this.handlePageChange}
261 switch (this.state.messageType) {
262 case MessageType.All: {
265 case MessageType.Replies: {
266 return this.replies();
268 case MessageType.Mentions: {
269 return this.mentions();
271 case MessageType.Messages: {
272 return this.messages();
280 unreadOrAllRadios() {
282 <div className="btn-group btn-group-toggle flex-wrap mb-2">
284 className={`btn btn-outline-secondary pointer
285 ${this.state.unreadOrAll == UnreadOrAll.Unread && "active"}
290 value={UnreadOrAll.Unread}
291 checked={this.state.unreadOrAll == UnreadOrAll.Unread}
292 onChange={linkEvent(this, this.handleUnreadOrAllChange)}
297 className={`btn btn-outline-secondary pointer
298 ${this.state.unreadOrAll == UnreadOrAll.All && "active"}
303 value={UnreadOrAll.All}
304 checked={this.state.unreadOrAll == UnreadOrAll.All}
305 onChange={linkEvent(this, this.handleUnreadOrAllChange)}
313 messageTypeRadios() {
315 <div className="btn-group btn-group-toggle flex-wrap mb-2">
317 className={`btn btn-outline-secondary pointer
318 ${this.state.messageType == MessageType.All && "active"}
323 value={MessageType.All}
324 checked={this.state.messageType == MessageType.All}
325 onChange={linkEvent(this, this.handleMessageTypeChange)}
330 className={`btn btn-outline-secondary pointer
331 ${this.state.messageType == MessageType.Replies && "active"}
336 value={MessageType.Replies}
337 checked={this.state.messageType == MessageType.Replies}
338 onChange={linkEvent(this, this.handleMessageTypeChange)}
343 className={`btn btn-outline-secondary pointer
344 ${this.state.messageType == MessageType.Mentions && "active"}
349 value={MessageType.Mentions}
350 checked={this.state.messageType == MessageType.Mentions}
351 onChange={linkEvent(this, this.handleMessageTypeChange)}
356 className={`btn btn-outline-secondary pointer
357 ${this.state.messageType == MessageType.Messages && "active"}
362 value={MessageType.Messages}
363 checked={this.state.messageType == MessageType.Messages}
364 onChange={linkEvent(this, this.handleMessageTypeChange)}
374 <div className="mb-2">
375 <span className="mr-3">{this.unreadOrAllRadios()}</span>
376 <span className="mr-3">{this.messageTypeRadios()}</span>
378 sort={this.state.sort}
379 onChange={this.handleSortChange}
385 replyToReplyType(r: CommentReplyView): ReplyType {
387 id: r.comment_reply.id,
388 type_: ReplyEnum.Reply,
390 published: r.comment.published,
394 mentionToReplyType(r: PersonMentionView): ReplyType {
396 id: r.person_mention.id,
397 type_: ReplyEnum.Mention,
399 published: r.comment.published,
403 messageToReplyType(r: PrivateMessageView): ReplyType {
405 id: r.private_message.id,
406 type_: ReplyEnum.Message,
408 published: r.private_message.published,
412 buildCombined(): ReplyType[] {
413 const replies: ReplyType[] =
414 this.state.repliesRes.state == "success"
415 ? this.state.repliesRes.data.replies.map(this.replyToReplyType)
417 const mentions: ReplyType[] =
418 this.state.mentionsRes.state == "success"
419 ? this.state.mentionsRes.data.mentions.map(this.mentionToReplyType)
421 const messages: ReplyType[] =
422 this.state.messagesRes.state == "success"
423 ? this.state.messagesRes.data.private_messages.map(
424 this.messageToReplyType
428 return [...replies, ...mentions, ...messages].sort((a, b) =>
429 b.published.localeCompare(a.published)
433 renderReplyType(i: ReplyType) {
435 case ReplyEnum.Reply:
440 { comment_view: i.view as CommentView, children: [], depth: 0 },
442 viewType={CommentViewType.Flat}
443 finished={this.state.finished}
448 enableDownvotes={enableDownvotes(this.state.siteRes)}
449 allLanguages={this.state.siteRes.all_languages}
450 siteLanguages={this.state.siteRes.discussion_languages}
451 onSaveComment={this.handleSaveComment}
452 onBlockPerson={this.handleBlockPerson}
453 onDeleteComment={this.handleDeleteComment}
454 onRemoveComment={this.handleRemoveComment}
455 onCommentVote={this.handleCommentVote}
456 onCommentReport={this.handleCommentReport}
457 onDistinguishComment={this.handleDistinguishComment}
458 onAddModToCommunity={this.handleAddModToCommunity}
459 onAddAdmin={this.handleAddAdmin}
460 onTransferCommunity={this.handleTransferCommunity}
461 onPurgeComment={this.handlePurgeComment}
462 onPurgePerson={this.handlePurgePerson}
463 onCommentReplyRead={this.handleCommentReplyRead}
464 onPersonMentionRead={this.handlePersonMentionRead}
465 onBanPersonFromCommunity={this.handleBanFromCommunity}
466 onBanPerson={this.handleBanPerson}
467 onCreateComment={this.handleCreateComment}
468 onEditComment={this.handleEditComment}
471 case ReplyEnum.Mention:
477 comment_view: i.view as PersonMentionView,
482 finished={this.state.finished}
483 viewType={CommentViewType.Flat}
488 enableDownvotes={enableDownvotes(this.state.siteRes)}
489 allLanguages={this.state.siteRes.all_languages}
490 siteLanguages={this.state.siteRes.discussion_languages}
491 onSaveComment={this.handleSaveComment}
492 onBlockPerson={this.handleBlockPerson}
493 onDeleteComment={this.handleDeleteComment}
494 onRemoveComment={this.handleRemoveComment}
495 onCommentVote={this.handleCommentVote}
496 onCommentReport={this.handleCommentReport}
497 onDistinguishComment={this.handleDistinguishComment}
498 onAddModToCommunity={this.handleAddModToCommunity}
499 onAddAdmin={this.handleAddAdmin}
500 onTransferCommunity={this.handleTransferCommunity}
501 onPurgeComment={this.handlePurgeComment}
502 onPurgePerson={this.handlePurgePerson}
503 onCommentReplyRead={this.handleCommentReplyRead}
504 onPersonMentionRead={this.handlePersonMentionRead}
505 onBanPersonFromCommunity={this.handleBanFromCommunity}
506 onBanPerson={this.handleBanPerson}
507 onCreateComment={this.handleCreateComment}
508 onEditComment={this.handleEditComment}
511 case ReplyEnum.Message:
515 private_message_view={i.view as PrivateMessageView}
516 onDelete={this.handleDeleteMessage}
517 onMarkRead={this.handleMarkMessageAsRead}
518 onReport={this.handleMessageReport}
519 onCreate={this.handleCreateMessage}
520 onEdit={this.handleEditMessage}
530 this.state.repliesRes.state == "loading" ||
531 this.state.mentionsRes.state == "loading" ||
532 this.state.messagesRes.state == "loading"
541 <div>{this.buildCombined().map(r => this.renderReplyType(r))}</div>
547 switch (this.state.repliesRes.state) {
555 const replies = this.state.repliesRes.data.replies;
559 nodes={commentsToFlatNodes(replies)}
560 viewType={CommentViewType.Flat}
561 finished={this.state.finished}
566 enableDownvotes={enableDownvotes(this.state.siteRes)}
567 allLanguages={this.state.siteRes.all_languages}
568 siteLanguages={this.state.siteRes.discussion_languages}
569 onSaveComment={this.handleSaveComment}
570 onBlockPerson={this.handleBlockPerson}
571 onDeleteComment={this.handleDeleteComment}
572 onRemoveComment={this.handleRemoveComment}
573 onCommentVote={this.handleCommentVote}
574 onCommentReport={this.handleCommentReport}
575 onDistinguishComment={this.handleDistinguishComment}
576 onAddModToCommunity={this.handleAddModToCommunity}
577 onAddAdmin={this.handleAddAdmin}
578 onTransferCommunity={this.handleTransferCommunity}
579 onPurgeComment={this.handlePurgeComment}
580 onPurgePerson={this.handlePurgePerson}
581 onCommentReplyRead={this.handleCommentReplyRead}
582 onPersonMentionRead={this.handlePersonMentionRead}
583 onBanPersonFromCommunity={this.handleBanFromCommunity}
584 onBanPerson={this.handleBanPerson}
585 onCreateComment={this.handleCreateComment}
586 onEditComment={this.handleEditComment}
595 switch (this.state.mentionsRes.state) {
603 const mentions = this.state.mentionsRes.data.mentions;
606 {mentions.map(umv => (
608 key={umv.person_mention.id}
609 nodes={[{ comment_view: umv, children: [], depth: 0 }]}
610 viewType={CommentViewType.Flat}
611 finished={this.state.finished}
616 enableDownvotes={enableDownvotes(this.state.siteRes)}
617 allLanguages={this.state.siteRes.all_languages}
618 siteLanguages={this.state.siteRes.discussion_languages}
619 onSaveComment={this.handleSaveComment}
620 onBlockPerson={this.handleBlockPerson}
621 onDeleteComment={this.handleDeleteComment}
622 onRemoveComment={this.handleRemoveComment}
623 onCommentVote={this.handleCommentVote}
624 onCommentReport={this.handleCommentReport}
625 onDistinguishComment={this.handleDistinguishComment}
626 onAddModToCommunity={this.handleAddModToCommunity}
627 onAddAdmin={this.handleAddAdmin}
628 onTransferCommunity={this.handleTransferCommunity}
629 onPurgeComment={this.handlePurgeComment}
630 onPurgePerson={this.handlePurgePerson}
631 onCommentReplyRead={this.handleCommentReplyRead}
632 onPersonMentionRead={this.handlePersonMentionRead}
633 onBanPersonFromCommunity={this.handleBanFromCommunity}
634 onBanPerson={this.handleBanPerson}
635 onCreateComment={this.handleCreateComment}
636 onEditComment={this.handleEditComment}
646 switch (this.state.messagesRes.state) {
654 const messages = this.state.messagesRes.data.private_messages;
657 {messages.map(pmv => (
659 key={pmv.private_message.id}
660 private_message_view={pmv}
661 onDelete={this.handleDeleteMessage}
662 onMarkRead={this.handleMarkMessageAsRead}
663 onReport={this.handleMessageReport}
664 onCreate={this.handleCreateMessage}
665 onEdit={this.handleEditMessage}
674 async handlePageChange(page: number) {
675 this.setState({ page });
676 await this.refetch();
679 async handleUnreadOrAllChange(i: Inbox, event: any) {
680 i.setState({ unreadOrAll: Number(event.target.value), page: 1 });
684 async handleMessageTypeChange(i: Inbox, event: any) {
685 i.setState({ messageType: Number(event.target.value), page: 1 });
689 static fetchInitialData({
692 }: InitialFetchRequest): Promise<any>[] {
693 const promises: Promise<RequestState<any>>[] = [];
695 const sort: CommentSortType = "New";
698 // It can be /u/me, or /username/1
699 const repliesForm: GetReplies = {
706 promises.push(client.getReplies(repliesForm));
708 const personMentionsForm: GetPersonMentions = {
715 promises.push(client.getPersonMentions(personMentionsForm));
717 const privateMessagesForm: GetPrivateMessages = {
723 promises.push(client.getPrivateMessages(privateMessagesForm));
726 Promise.resolve({ state: "empty" }),
727 Promise.resolve({ state: "empty" }),
728 Promise.resolve({ state: "empty" })
736 const sort = this.state.sort;
737 const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread;
738 const page = this.state.page;
739 const limit = fetchLimit;
740 const auth = myAuthRequired();
742 this.setState({ repliesRes: { state: "loading" } });
744 repliesRes: await HttpService.client.getReplies({
753 this.setState({ mentionsRes: { state: "loading" } });
755 mentionsRes: await HttpService.client.getPersonMentions({
764 this.setState({ messagesRes: { state: "loading" } });
766 messagesRes: await HttpService.client.getPrivateMessages({
775 async handleSortChange(val: CommentSortType) {
776 this.setState({ sort: val, page: 1 });
777 await this.refetch();
780 async handleMarkAllAsRead(i: Inbox) {
781 i.setState({ markAllAsReadRes: { state: "loading" } });
784 markAllAsReadRes: await HttpService.client.markAllAsRead({
785 auth: myAuthRequired(),
789 if (i.state.markAllAsReadRes.state == "success") {
791 repliesRes: { state: "empty" },
792 mentionsRes: { state: "empty" },
793 messagesRes: { state: "empty" },
798 async handleAddModToCommunity(form: AddModToCommunity) {
799 // TODO not sure what to do here
800 HttpService.client.addModToCommunity(form);
803 async handlePurgePerson(form: PurgePerson) {
804 const purgePersonRes = await HttpService.client.purgePerson(form);
805 this.purgeItem(purgePersonRes);
808 async handlePurgeComment(form: PurgeComment) {
809 const purgeCommentRes = await HttpService.client.purgeComment(form);
810 this.purgeItem(purgeCommentRes);
813 async handlePurgePost(form: PurgePost) {
814 const purgeRes = await HttpService.client.purgePost(form);
815 this.purgeItem(purgeRes);
818 async handleBlockPerson(form: BlockPerson) {
819 const blockPersonRes = await HttpService.client.blockPerson(form);
820 if (blockPersonRes.state == "success") {
821 updatePersonBlock(blockPersonRes.data);
825 async handleCreateComment(form: CreateComment) {
826 const res = await HttpService.client.createComment(form);
828 if (res.state === "success") {
829 toast(i18n.t("reply_sent"));
830 this.findAndUpdateComment(res);
836 async handleEditComment(form: EditComment) {
837 const res = await HttpService.client.editComment(form);
839 if (res.state === "success") {
840 toast(i18n.t("edit"));
841 this.findAndUpdateComment(res);
842 } else if (res.state === "failed") {
843 toast(res.msg, "danger");
849 async handleDeleteComment(form: DeleteComment) {
850 const res = await HttpService.client.deleteComment(form);
851 if (res.state == "success") {
852 toast(i18n.t("deleted"));
853 this.findAndUpdateComment(res);
857 async handleRemoveComment(form: RemoveComment) {
858 const res = await HttpService.client.removeComment(form);
859 if (res.state == "success") {
860 toast(i18n.t("remove_comment"));
861 this.findAndUpdateComment(res);
865 async handleSaveComment(form: SaveComment) {
866 const res = await HttpService.client.saveComment(form);
867 this.findAndUpdateComment(res);
870 async handleCommentVote(form: CreateCommentLike) {
871 const res = await HttpService.client.likeComment(form);
872 this.findAndUpdateComment(res);
875 async handleCommentReport(form: CreateCommentReport) {
876 const reportRes = await HttpService.client.createCommentReport(form);
877 this.reportToast(reportRes);
880 async handleDistinguishComment(form: DistinguishComment) {
881 const res = await HttpService.client.distinguishComment(form);
882 this.findAndUpdateComment(res);
885 async handleAddAdmin(form: AddAdmin) {
886 const addAdminRes = await HttpService.client.addAdmin(form);
888 if (addAdminRes.state === "success") {
889 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
893 async handleTransferCommunity(form: TransferCommunity) {
894 await HttpService.client.transferCommunity(form);
895 toast(i18n.t("transfer_community"));
898 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
899 const res = await HttpService.client.markCommentReplyAsRead(form);
900 this.findAndUpdateCommentReply(res);
903 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
904 const res = await HttpService.client.markPersonMentionAsRead(form);
905 this.findAndUpdateMention(res);
908 async handleBanFromCommunity(form: BanFromCommunity) {
909 const banRes = await HttpService.client.banFromCommunity(form);
910 this.updateBanFromCommunity(banRes);
913 async handleBanPerson(form: BanPerson) {
914 const banRes = await HttpService.client.banPerson(form);
915 this.updateBan(banRes);
918 async handleDeleteMessage(form: DeletePrivateMessage) {
919 const res = await HttpService.client.deletePrivateMessage(form);
920 this.findAndUpdateMessage(res);
923 async handleEditMessage(form: EditPrivateMessage) {
924 const res = await HttpService.client.editPrivateMessage(form);
925 this.findAndUpdateMessage(res);
928 async handleMarkMessageAsRead(form: MarkPrivateMessageAsRead) {
929 const res = await HttpService.client.markPrivateMessageAsRead(form);
930 this.findAndUpdateMessage(res);
933 async handleMessageReport(form: CreatePrivateMessageReport) {
934 const res = await HttpService.client.createPrivateMessageReport(form);
935 this.reportToast(res);
938 async handleCreateMessage(form: CreatePrivateMessage) {
939 const res = await HttpService.client.createPrivateMessage(form);
941 if (s.messagesRes.state == "success" && res.state == "success") {
942 s.messagesRes.data.private_messages.unshift(
943 res.data.private_message_view
951 findAndUpdateMessage(res: RequestState<PrivateMessageResponse>) {
953 if (s.messagesRes.state === "success" && res.state === "success") {
954 s.messagesRes.data.private_messages = editPrivateMessage(
955 res.data.private_message_view,
956 s.messagesRes.data.private_messages
963 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
964 // Maybe not necessary
965 if (banRes.state == "success") {
967 if (s.repliesRes.state == "success") {
968 s.repliesRes.data.replies
969 .filter(c => c.creator.id == banRes.data.person_view.person.id)
971 c => (c.creator_banned_from_community = banRes.data.banned)
974 if (s.mentionsRes.state == "success") {
975 s.mentionsRes.data.mentions
976 .filter(c => c.creator.id == banRes.data.person_view.person.id)
978 c => (c.creator_banned_from_community = banRes.data.banned)
986 updateBan(banRes: RequestState<BanPersonResponse>) {
987 // Maybe not necessary
988 if (banRes.state == "success") {
990 if (s.repliesRes.state == "success") {
991 s.repliesRes.data.replies
992 .filter(c => c.creator.id == banRes.data.person_view.person.id)
993 .forEach(c => (c.creator.banned = banRes.data.banned));
995 if (s.mentionsRes.state == "success") {
996 s.mentionsRes.data.mentions
997 .filter(c => c.creator.id == banRes.data.person_view.person.id)
998 .forEach(c => (c.creator.banned = banRes.data.banned));
1005 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1006 if (purgeRes.state == "success") {
1007 toast(i18n.t("purge_success"));
1008 this.context.router.history.push(`/`);
1013 res: RequestState<PrivateMessageReportResponse | CommentReportResponse>
1015 if (res.state == "success") {
1016 toast(i18n.t("report_created"));
1020 // A weird case, since you have only replies and mentions, not comment responses
1021 findAndUpdateComment(res: RequestState<CommentResponse>) {
1022 if (res.state == "success") {
1023 this.setState(s => {
1024 if (s.repliesRes.state == "success") {
1025 s.repliesRes.data.replies = editWith(
1026 res.data.comment_view,
1027 s.repliesRes.data.replies
1030 if (s.mentionsRes.state == "success") {
1031 s.mentionsRes.data.mentions = editWith(
1032 res.data.comment_view,
1033 s.mentionsRes.data.mentions
1036 // Set finished for the parent
1038 getCommentParentId(res.data.comment_view.comment) ?? 0,
1046 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1047 this.setState(s => {
1048 if (s.repliesRes.state == "success" && res.state == "success") {
1049 s.repliesRes.data.replies = editCommentReply(
1050 res.data.comment_reply_view,
1051 s.repliesRes.data.replies
1058 findAndUpdateMention(res: RequestState<PersonMentionResponse>) {
1059 this.setState(s => {
1060 if (s.mentionsRes.state == "success" && res.state == "success") {
1061 s.mentionsRes.data.mentions = editMention(
1062 res.data.person_mention_view,
1063 s.mentionsRes.data.mentions