1 import { Component, linkEvent } from "inferno";
6 BanFromCommunityResponse,
13 CommentReportResponse,
21 CreatePrivateMessageReport,
27 GetPersonMentionsResponse,
30 MarkCommentReplyAsRead,
31 MarkPersonMentionAsRead,
32 MarkPrivateMessageAsRead,
33 PersonMentionResponse,
35 PrivateMessageReportResponse,
36 PrivateMessageResponse,
38 PrivateMessagesResponse,
46 } from "lemmy-js-client";
47 import { i18n } from "../../i18next";
48 import { CommentViewType, InitialFetchRequest } from "../../interfaces";
49 import { UserService } from "../../services";
50 import { FirstLoadService } from "../../services/FirstLoadService";
51 import { HttpService, RequestState } from "../../services/HttpService";
69 import { CommentNodes } from "../comment/comment-nodes";
70 import { CommentSortSelect } from "../common/comment-sort-select";
71 import { HtmlTags } from "../common/html-tags";
72 import { Icon, Spinner } from "../common/icon";
73 import { Paginator } from "../common/paginator";
74 import { PrivateMessage } from "../private_message/private-message";
94 type InboxData = RouteDataResponse<{
95 repliesRes: GetRepliesResponse;
96 mentionsRes: GetPersonMentionsResponse;
97 messagesRes: PrivateMessagesResponse;
103 view: CommentView | PrivateMessageView | PersonMentionView | CommentReplyView;
107 interface InboxState {
108 unreadOrAll: UnreadOrAll;
109 messageType: MessageType;
110 repliesRes: RequestState<GetRepliesResponse>;
111 mentionsRes: RequestState<GetPersonMentionsResponse>;
112 messagesRes: RequestState<PrivateMessagesResponse>;
113 markAllAsReadRes: RequestState<GetRepliesResponse>;
114 sort: CommentSortType;
116 siteRes: GetSiteResponse;
117 finished: Map<CommentId, boolean | undefined>;
118 isIsomorphic: boolean;
121 export class Inbox extends Component<any, InboxState> {
122 private isoData = setIsoData<InboxData>(this.context);
123 state: InboxState = {
124 unreadOrAll: UnreadOrAll.Unread,
125 messageType: MessageType.All,
128 siteRes: this.isoData.site_res,
129 repliesRes: { state: "empty" },
130 mentionsRes: { state: "empty" },
131 messagesRes: { state: "empty" },
132 markAllAsReadRes: { state: "empty" },
137 constructor(props: any, context: any) {
138 super(props, context);
140 this.handleSortChange = this.handleSortChange.bind(this);
141 this.handlePageChange = this.handlePageChange.bind(this);
143 this.handleCreateComment = this.handleCreateComment.bind(this);
144 this.handleEditComment = this.handleEditComment.bind(this);
145 this.handleSaveComment = this.handleSaveComment.bind(this);
146 this.handleBlockPerson = this.handleBlockPerson.bind(this);
147 this.handleDeleteComment = this.handleDeleteComment.bind(this);
148 this.handleRemoveComment = this.handleRemoveComment.bind(this);
149 this.handleCommentVote = this.handleCommentVote.bind(this);
150 this.handleAddModToCommunity = this.handleAddModToCommunity.bind(this);
151 this.handleAddAdmin = this.handleAddAdmin.bind(this);
152 this.handlePurgePerson = this.handlePurgePerson.bind(this);
153 this.handlePurgeComment = this.handlePurgeComment.bind(this);
154 this.handleCommentReport = this.handleCommentReport.bind(this);
155 this.handleDistinguishComment = this.handleDistinguishComment.bind(this);
156 this.handleTransferCommunity = this.handleTransferCommunity.bind(this);
157 this.handleCommentReplyRead = this.handleCommentReplyRead.bind(this);
158 this.handlePersonMentionRead = this.handlePersonMentionRead.bind(this);
159 this.handleBanFromCommunity = this.handleBanFromCommunity.bind(this);
160 this.handleBanPerson = this.handleBanPerson.bind(this);
162 this.handleDeleteMessage = this.handleDeleteMessage.bind(this);
163 this.handleMarkMessageAsRead = this.handleMarkMessageAsRead.bind(this);
164 this.handleMessageReport = this.handleMessageReport.bind(this);
165 this.handleCreateMessage = this.handleCreateMessage.bind(this);
166 this.handleEditMessage = this.handleEditMessage.bind(this);
168 // Only fetch the data if coming from another route
169 if (FirstLoadService.isFirstLoad) {
170 const { mentionsRes, messagesRes, repliesRes } = this.isoData.routeData;
182 async componentDidMount() {
183 if (!this.state.isIsomorphic) {
184 await this.refetch();
188 get documentTitle(): string {
189 const mui = UserService.Instance.myUserInfo;
191 ? `@${mui.local_user_view.person.name} ${i18n.t("inbox")} - ${
192 this.state.siteRes.site_view.site.name
197 get hasUnreads(): boolean {
198 if (this.state.unreadOrAll == UnreadOrAll.Unread) {
199 const { repliesRes, mentionsRes, messagesRes } = this.state;
201 repliesRes.state == "success" ? repliesRes.data.replies.length : 0;
203 mentionsRes.state == "success" ? mentionsRes.data.mentions.length : 0;
205 messagesRes.state == "success"
206 ? messagesRes.data.private_messages.length
209 return replyCount + mentionCount + messageCount > 0;
216 const auth = myAuth();
217 const inboxRss = auth ? `/feeds/inbox/${auth}.xml` : undefined;
219 <div className="container-lg">
220 <div className="row">
221 <div className="col-12">
223 title={this.documentTitle}
224 path={this.context.router.route.match.url}
226 <h5 className="mb-2">
230 <a href={inboxRss} title="RSS" rel={relTags}>
231 <Icon icon="rss" classes="ml-2 text-muted small" />
235 type="application/atom+xml"
241 {this.hasUnreads && (
243 className="btn btn-secondary mb-2"
244 onClick={linkEvent(this, this.handleMarkAllAsRead)}
246 {this.state.markAllAsReadRes.state == "loading" ? (
249 i18n.t("mark_all_as_read")
256 page={this.state.page}
257 onChange={this.handlePageChange}
266 switch (this.state.messageType) {
267 case MessageType.All: {
270 case MessageType.Replies: {
271 return this.replies();
273 case MessageType.Mentions: {
274 return this.mentions();
276 case MessageType.Messages: {
277 return this.messages();
285 unreadOrAllRadios() {
287 <div className="btn-group btn-group-toggle flex-wrap mb-2">
289 className={`btn btn-outline-secondary pointer
290 ${this.state.unreadOrAll == UnreadOrAll.Unread && "active"}
295 value={UnreadOrAll.Unread}
296 checked={this.state.unreadOrAll == UnreadOrAll.Unread}
297 onChange={linkEvent(this, this.handleUnreadOrAllChange)}
302 className={`btn btn-outline-secondary pointer
303 ${this.state.unreadOrAll == UnreadOrAll.All && "active"}
308 value={UnreadOrAll.All}
309 checked={this.state.unreadOrAll == UnreadOrAll.All}
310 onChange={linkEvent(this, this.handleUnreadOrAllChange)}
318 messageTypeRadios() {
320 <div className="btn-group btn-group-toggle flex-wrap mb-2">
322 className={`btn btn-outline-secondary pointer
323 ${this.state.messageType == MessageType.All && "active"}
328 value={MessageType.All}
329 checked={this.state.messageType == MessageType.All}
330 onChange={linkEvent(this, this.handleMessageTypeChange)}
335 className={`btn btn-outline-secondary pointer
336 ${this.state.messageType == MessageType.Replies && "active"}
341 value={MessageType.Replies}
342 checked={this.state.messageType == MessageType.Replies}
343 onChange={linkEvent(this, this.handleMessageTypeChange)}
348 className={`btn btn-outline-secondary pointer
349 ${this.state.messageType == MessageType.Mentions && "active"}
354 value={MessageType.Mentions}
355 checked={this.state.messageType == MessageType.Mentions}
356 onChange={linkEvent(this, this.handleMessageTypeChange)}
361 className={`btn btn-outline-secondary pointer
362 ${this.state.messageType == MessageType.Messages && "active"}
367 value={MessageType.Messages}
368 checked={this.state.messageType == MessageType.Messages}
369 onChange={linkEvent(this, this.handleMessageTypeChange)}
379 <div className="mb-2">
380 <span className="mr-3">{this.unreadOrAllRadios()}</span>
381 <span className="mr-3">{this.messageTypeRadios()}</span>
383 sort={this.state.sort}
384 onChange={this.handleSortChange}
390 replyToReplyType(r: CommentReplyView): ReplyType {
392 id: r.comment_reply.id,
393 type_: ReplyEnum.Reply,
395 published: r.comment.published,
399 mentionToReplyType(r: PersonMentionView): ReplyType {
401 id: r.person_mention.id,
402 type_: ReplyEnum.Mention,
404 published: r.comment.published,
408 messageToReplyType(r: PrivateMessageView): ReplyType {
410 id: r.private_message.id,
411 type_: ReplyEnum.Message,
413 published: r.private_message.published,
417 buildCombined(): ReplyType[] {
418 const replies: ReplyType[] =
419 this.state.repliesRes.state == "success"
420 ? this.state.repliesRes.data.replies.map(this.replyToReplyType)
422 const mentions: ReplyType[] =
423 this.state.mentionsRes.state == "success"
424 ? this.state.mentionsRes.data.mentions.map(this.mentionToReplyType)
426 const messages: ReplyType[] =
427 this.state.messagesRes.state == "success"
428 ? this.state.messagesRes.data.private_messages.map(
429 this.messageToReplyType
433 return [...replies, ...mentions, ...messages].sort((a, b) =>
434 b.published.localeCompare(a.published)
438 renderReplyType(i: ReplyType) {
440 case ReplyEnum.Reply:
445 { comment_view: i.view as CommentView, children: [], depth: 0 },
447 viewType={CommentViewType.Flat}
448 finished={this.state.finished}
453 enableDownvotes={enableDownvotes(this.state.siteRes)}
454 allLanguages={this.state.siteRes.all_languages}
455 siteLanguages={this.state.siteRes.discussion_languages}
456 onSaveComment={this.handleSaveComment}
457 onBlockPerson={this.handleBlockPerson}
458 onDeleteComment={this.handleDeleteComment}
459 onRemoveComment={this.handleRemoveComment}
460 onCommentVote={this.handleCommentVote}
461 onCommentReport={this.handleCommentReport}
462 onDistinguishComment={this.handleDistinguishComment}
463 onAddModToCommunity={this.handleAddModToCommunity}
464 onAddAdmin={this.handleAddAdmin}
465 onTransferCommunity={this.handleTransferCommunity}
466 onPurgeComment={this.handlePurgeComment}
467 onPurgePerson={this.handlePurgePerson}
468 onCommentReplyRead={this.handleCommentReplyRead}
469 onPersonMentionRead={this.handlePersonMentionRead}
470 onBanPersonFromCommunity={this.handleBanFromCommunity}
471 onBanPerson={this.handleBanPerson}
472 onCreateComment={this.handleCreateComment}
473 onEditComment={this.handleEditComment}
476 case ReplyEnum.Mention:
482 comment_view: i.view as PersonMentionView,
487 finished={this.state.finished}
488 viewType={CommentViewType.Flat}
493 enableDownvotes={enableDownvotes(this.state.siteRes)}
494 allLanguages={this.state.siteRes.all_languages}
495 siteLanguages={this.state.siteRes.discussion_languages}
496 onSaveComment={this.handleSaveComment}
497 onBlockPerson={this.handleBlockPerson}
498 onDeleteComment={this.handleDeleteComment}
499 onRemoveComment={this.handleRemoveComment}
500 onCommentVote={this.handleCommentVote}
501 onCommentReport={this.handleCommentReport}
502 onDistinguishComment={this.handleDistinguishComment}
503 onAddModToCommunity={this.handleAddModToCommunity}
504 onAddAdmin={this.handleAddAdmin}
505 onTransferCommunity={this.handleTransferCommunity}
506 onPurgeComment={this.handlePurgeComment}
507 onPurgePerson={this.handlePurgePerson}
508 onCommentReplyRead={this.handleCommentReplyRead}
509 onPersonMentionRead={this.handlePersonMentionRead}
510 onBanPersonFromCommunity={this.handleBanFromCommunity}
511 onBanPerson={this.handleBanPerson}
512 onCreateComment={this.handleCreateComment}
513 onEditComment={this.handleEditComment}
516 case ReplyEnum.Message:
520 private_message_view={i.view as PrivateMessageView}
521 onDelete={this.handleDeleteMessage}
522 onMarkRead={this.handleMarkMessageAsRead}
523 onReport={this.handleMessageReport}
524 onCreate={this.handleCreateMessage}
525 onEdit={this.handleEditMessage}
535 this.state.repliesRes.state == "loading" ||
536 this.state.mentionsRes.state == "loading" ||
537 this.state.messagesRes.state == "loading"
546 <div>{this.buildCombined().map(r => this.renderReplyType(r))}</div>
552 switch (this.state.repliesRes.state) {
560 const replies = this.state.repliesRes.data.replies;
564 nodes={commentsToFlatNodes(replies)}
565 viewType={CommentViewType.Flat}
566 finished={this.state.finished}
571 enableDownvotes={enableDownvotes(this.state.siteRes)}
572 allLanguages={this.state.siteRes.all_languages}
573 siteLanguages={this.state.siteRes.discussion_languages}
574 onSaveComment={this.handleSaveComment}
575 onBlockPerson={this.handleBlockPerson}
576 onDeleteComment={this.handleDeleteComment}
577 onRemoveComment={this.handleRemoveComment}
578 onCommentVote={this.handleCommentVote}
579 onCommentReport={this.handleCommentReport}
580 onDistinguishComment={this.handleDistinguishComment}
581 onAddModToCommunity={this.handleAddModToCommunity}
582 onAddAdmin={this.handleAddAdmin}
583 onTransferCommunity={this.handleTransferCommunity}
584 onPurgeComment={this.handlePurgeComment}
585 onPurgePerson={this.handlePurgePerson}
586 onCommentReplyRead={this.handleCommentReplyRead}
587 onPersonMentionRead={this.handlePersonMentionRead}
588 onBanPersonFromCommunity={this.handleBanFromCommunity}
589 onBanPerson={this.handleBanPerson}
590 onCreateComment={this.handleCreateComment}
591 onEditComment={this.handleEditComment}
600 switch (this.state.mentionsRes.state) {
608 const mentions = this.state.mentionsRes.data.mentions;
611 {mentions.map(umv => (
613 key={umv.person_mention.id}
614 nodes={[{ comment_view: umv, children: [], depth: 0 }]}
615 viewType={CommentViewType.Flat}
616 finished={this.state.finished}
621 enableDownvotes={enableDownvotes(this.state.siteRes)}
622 allLanguages={this.state.siteRes.all_languages}
623 siteLanguages={this.state.siteRes.discussion_languages}
624 onSaveComment={this.handleSaveComment}
625 onBlockPerson={this.handleBlockPerson}
626 onDeleteComment={this.handleDeleteComment}
627 onRemoveComment={this.handleRemoveComment}
628 onCommentVote={this.handleCommentVote}
629 onCommentReport={this.handleCommentReport}
630 onDistinguishComment={this.handleDistinguishComment}
631 onAddModToCommunity={this.handleAddModToCommunity}
632 onAddAdmin={this.handleAddAdmin}
633 onTransferCommunity={this.handleTransferCommunity}
634 onPurgeComment={this.handlePurgeComment}
635 onPurgePerson={this.handlePurgePerson}
636 onCommentReplyRead={this.handleCommentReplyRead}
637 onPersonMentionRead={this.handlePersonMentionRead}
638 onBanPersonFromCommunity={this.handleBanFromCommunity}
639 onBanPerson={this.handleBanPerson}
640 onCreateComment={this.handleCreateComment}
641 onEditComment={this.handleEditComment}
651 switch (this.state.messagesRes.state) {
659 const messages = this.state.messagesRes.data.private_messages;
662 {messages.map(pmv => (
664 key={pmv.private_message.id}
665 private_message_view={pmv}
666 onDelete={this.handleDeleteMessage}
667 onMarkRead={this.handleMarkMessageAsRead}
668 onReport={this.handleMessageReport}
669 onCreate={this.handleCreateMessage}
670 onEdit={this.handleEditMessage}
679 async handlePageChange(page: number) {
680 this.setState({ page });
681 await this.refetch();
684 async handleUnreadOrAllChange(i: Inbox, event: any) {
685 i.setState({ unreadOrAll: Number(event.target.value), page: 1 });
689 async handleMessageTypeChange(i: Inbox, event: any) {
690 i.setState({ messageType: Number(event.target.value), page: 1 });
694 static async fetchInitialData({
697 }: InitialFetchRequest): Promise<InboxData> {
698 const sort: CommentSortType = "New";
702 ? await client.getPersonMentions({
709 : { state: "empty" },
711 ? await client.getPrivateMessages({
717 : { state: "empty" },
719 ? await client.getReplies({
726 : { state: "empty" },
731 const sort = this.state.sort;
732 const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread;
733 const page = this.state.page;
734 const limit = fetchLimit;
735 const auth = myAuthRequired();
737 this.setState({ repliesRes: { state: "loading" } });
739 repliesRes: await HttpService.client.getReplies({
748 this.setState({ mentionsRes: { state: "loading" } });
750 mentionsRes: await HttpService.client.getPersonMentions({
759 this.setState({ messagesRes: { state: "loading" } });
761 messagesRes: await HttpService.client.getPrivateMessages({
770 async handleSortChange(val: CommentSortType) {
771 this.setState({ sort: val, page: 1 });
772 await this.refetch();
775 async handleMarkAllAsRead(i: Inbox) {
776 i.setState({ markAllAsReadRes: { state: "loading" } });
779 markAllAsReadRes: await HttpService.client.markAllAsRead({
780 auth: myAuthRequired(),
784 if (i.state.markAllAsReadRes.state == "success") {
786 repliesRes: { state: "empty" },
787 mentionsRes: { state: "empty" },
788 messagesRes: { state: "empty" },
793 async handleAddModToCommunity(form: AddModToCommunity) {
794 // TODO not sure what to do here
795 HttpService.client.addModToCommunity(form);
798 async handlePurgePerson(form: PurgePerson) {
799 const purgePersonRes = await HttpService.client.purgePerson(form);
800 this.purgeItem(purgePersonRes);
803 async handlePurgeComment(form: PurgeComment) {
804 const purgeCommentRes = await HttpService.client.purgeComment(form);
805 this.purgeItem(purgeCommentRes);
808 async handlePurgePost(form: PurgePost) {
809 const purgeRes = await HttpService.client.purgePost(form);
810 this.purgeItem(purgeRes);
813 async handleBlockPerson(form: BlockPerson) {
814 const blockPersonRes = await HttpService.client.blockPerson(form);
815 if (blockPersonRes.state == "success") {
816 updatePersonBlock(blockPersonRes.data);
820 async handleCreateComment(form: CreateComment) {
821 const res = await HttpService.client.createComment(form);
823 if (res.state === "success") {
824 toast(i18n.t("reply_sent"));
825 this.findAndUpdateComment(res);
831 async handleEditComment(form: EditComment) {
832 const res = await HttpService.client.editComment(form);
834 if (res.state === "success") {
835 toast(i18n.t("edit"));
836 this.findAndUpdateComment(res);
837 } else if (res.state === "failed") {
838 toast(res.msg, "danger");
844 async handleDeleteComment(form: DeleteComment) {
845 const res = await HttpService.client.deleteComment(form);
846 if (res.state == "success") {
847 toast(i18n.t("deleted"));
848 this.findAndUpdateComment(res);
852 async handleRemoveComment(form: RemoveComment) {
853 const res = await HttpService.client.removeComment(form);
854 if (res.state == "success") {
855 toast(i18n.t("remove_comment"));
856 this.findAndUpdateComment(res);
860 async handleSaveComment(form: SaveComment) {
861 const res = await HttpService.client.saveComment(form);
862 this.findAndUpdateComment(res);
865 async handleCommentVote(form: CreateCommentLike) {
866 const res = await HttpService.client.likeComment(form);
867 this.findAndUpdateComment(res);
870 async handleCommentReport(form: CreateCommentReport) {
871 const reportRes = await HttpService.client.createCommentReport(form);
872 this.reportToast(reportRes);
875 async handleDistinguishComment(form: DistinguishComment) {
876 const res = await HttpService.client.distinguishComment(form);
877 this.findAndUpdateComment(res);
880 async handleAddAdmin(form: AddAdmin) {
881 const addAdminRes = await HttpService.client.addAdmin(form);
883 if (addAdminRes.state === "success") {
884 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
888 async handleTransferCommunity(form: TransferCommunity) {
889 await HttpService.client.transferCommunity(form);
890 toast(i18n.t("transfer_community"));
893 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
894 const res = await HttpService.client.markCommentReplyAsRead(form);
895 this.findAndUpdateCommentReply(res);
898 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
899 const res = await HttpService.client.markPersonMentionAsRead(form);
900 this.findAndUpdateMention(res);
903 async handleBanFromCommunity(form: BanFromCommunity) {
904 const banRes = await HttpService.client.banFromCommunity(form);
905 this.updateBanFromCommunity(banRes);
908 async handleBanPerson(form: BanPerson) {
909 const banRes = await HttpService.client.banPerson(form);
910 this.updateBan(banRes);
913 async handleDeleteMessage(form: DeletePrivateMessage) {
914 const res = await HttpService.client.deletePrivateMessage(form);
915 this.findAndUpdateMessage(res);
918 async handleEditMessage(form: EditPrivateMessage) {
919 const res = await HttpService.client.editPrivateMessage(form);
920 this.findAndUpdateMessage(res);
923 async handleMarkMessageAsRead(form: MarkPrivateMessageAsRead) {
924 const res = await HttpService.client.markPrivateMessageAsRead(form);
925 this.findAndUpdateMessage(res);
928 async handleMessageReport(form: CreatePrivateMessageReport) {
929 const res = await HttpService.client.createPrivateMessageReport(form);
930 this.reportToast(res);
933 async handleCreateMessage(form: CreatePrivateMessage) {
934 const res = await HttpService.client.createPrivateMessage(form);
936 if (s.messagesRes.state == "success" && res.state == "success") {
937 s.messagesRes.data.private_messages.unshift(
938 res.data.private_message_view
946 findAndUpdateMessage(res: RequestState<PrivateMessageResponse>) {
948 if (s.messagesRes.state === "success" && res.state === "success") {
949 s.messagesRes.data.private_messages = editPrivateMessage(
950 res.data.private_message_view,
951 s.messagesRes.data.private_messages
958 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
959 // Maybe not necessary
960 if (banRes.state == "success") {
962 if (s.repliesRes.state == "success") {
963 s.repliesRes.data.replies
964 .filter(c => c.creator.id == banRes.data.person_view.person.id)
966 c => (c.creator_banned_from_community = banRes.data.banned)
969 if (s.mentionsRes.state == "success") {
970 s.mentionsRes.data.mentions
971 .filter(c => c.creator.id == banRes.data.person_view.person.id)
973 c => (c.creator_banned_from_community = banRes.data.banned)
981 updateBan(banRes: RequestState<BanPersonResponse>) {
982 // Maybe not necessary
983 if (banRes.state == "success") {
985 if (s.repliesRes.state == "success") {
986 s.repliesRes.data.replies
987 .filter(c => c.creator.id == banRes.data.person_view.person.id)
988 .forEach(c => (c.creator.banned = banRes.data.banned));
990 if (s.mentionsRes.state == "success") {
991 s.mentionsRes.data.mentions
992 .filter(c => c.creator.id == banRes.data.person_view.person.id)
993 .forEach(c => (c.creator.banned = banRes.data.banned));
1000 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1001 if (purgeRes.state == "success") {
1002 toast(i18n.t("purge_success"));
1003 this.context.router.history.push(`/`);
1008 res: RequestState<PrivateMessageReportResponse | CommentReportResponse>
1010 if (res.state == "success") {
1011 toast(i18n.t("report_created"));
1015 // A weird case, since you have only replies and mentions, not comment responses
1016 findAndUpdateComment(res: RequestState<CommentResponse>) {
1017 if (res.state == "success") {
1018 this.setState(s => {
1019 if (s.repliesRes.state == "success") {
1020 s.repliesRes.data.replies = editWith(
1021 res.data.comment_view,
1022 s.repliesRes.data.replies
1025 if (s.mentionsRes.state == "success") {
1026 s.mentionsRes.data.mentions = editWith(
1027 res.data.comment_view,
1028 s.mentionsRes.data.mentions
1031 // Set finished for the parent
1033 getCommentParentId(res.data.comment_view.comment) ?? 0,
1041 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1042 this.setState(s => {
1043 if (s.repliesRes.state == "success" && res.state == "success") {
1044 s.repliesRes.data.replies = editCommentReply(
1045 res.data.comment_reply_view,
1046 s.repliesRes.data.replies
1053 findAndUpdateMention(res: RequestState<PersonMentionResponse>) {
1054 this.setState(s => {
1055 if (s.mentionsRes.state == "success" && res.state == "success") {
1056 s.mentionsRes.data.mentions = editMention(
1057 res.data.person_mention_view,
1058 s.mentionsRes.data.mentions