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 repliesResponse: GetRepliesResponse;
96 personMentionsResponse: GetPersonMentionsResponse;
97 privateMessagesResponse: 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) {
171 personMentionsResponse: mentionsRes,
172 privateMessagesResponse: messagesRes,
173 repliesResponse: repliesRes,
174 } = this.isoData.routeData;
186 async componentDidMount() {
187 if (!this.state.isIsomorphic) {
188 await this.refetch();
192 get documentTitle(): string {
193 const mui = UserService.Instance.myUserInfo;
195 ? `@${mui.local_user_view.person.name} ${i18n.t("inbox")} - ${
196 this.state.siteRes.site_view.site.name
201 get hasUnreads(): boolean {
202 if (this.state.unreadOrAll == UnreadOrAll.Unread) {
203 const { repliesRes, mentionsRes, messagesRes } = this.state;
205 repliesRes.state == "success" ? repliesRes.data.replies.length : 0;
207 mentionsRes.state == "success" ? mentionsRes.data.mentions.length : 0;
209 messagesRes.state == "success"
210 ? messagesRes.data.private_messages.length
213 return replyCount + mentionCount + messageCount > 0;
220 const auth = myAuth();
221 const inboxRss = auth ? `/feeds/inbox/${auth}.xml` : undefined;
223 <div className="container-lg">
224 <div className="row">
225 <div className="col-12">
227 title={this.documentTitle}
228 path={this.context.router.route.match.url}
230 <h5 className="mb-2">
234 <a href={inboxRss} title="RSS" rel={relTags}>
235 <Icon icon="rss" classes="ml-2 text-muted small" />
239 type="application/atom+xml"
245 {this.hasUnreads && (
247 className="btn btn-secondary mb-2"
248 onClick={linkEvent(this, this.handleMarkAllAsRead)}
250 {this.state.markAllAsReadRes.state == "loading" ? (
253 i18n.t("mark_all_as_read")
260 page={this.state.page}
261 onChange={this.handlePageChange}
270 switch (this.state.messageType) {
271 case MessageType.All: {
274 case MessageType.Replies: {
275 return this.replies();
277 case MessageType.Mentions: {
278 return this.mentions();
280 case MessageType.Messages: {
281 return this.messages();
289 unreadOrAllRadios() {
291 <div className="btn-group btn-group-toggle flex-wrap mb-2">
293 className={`btn btn-outline-secondary pointer
294 ${this.state.unreadOrAll == UnreadOrAll.Unread && "active"}
299 value={UnreadOrAll.Unread}
300 checked={this.state.unreadOrAll == UnreadOrAll.Unread}
301 onChange={linkEvent(this, this.handleUnreadOrAllChange)}
306 className={`btn btn-outline-secondary pointer
307 ${this.state.unreadOrAll == UnreadOrAll.All && "active"}
312 value={UnreadOrAll.All}
313 checked={this.state.unreadOrAll == UnreadOrAll.All}
314 onChange={linkEvent(this, this.handleUnreadOrAllChange)}
322 messageTypeRadios() {
324 <div className="btn-group btn-group-toggle flex-wrap mb-2">
326 className={`btn btn-outline-secondary pointer
327 ${this.state.messageType == MessageType.All && "active"}
332 value={MessageType.All}
333 checked={this.state.messageType == MessageType.All}
334 onChange={linkEvent(this, this.handleMessageTypeChange)}
339 className={`btn btn-outline-secondary pointer
340 ${this.state.messageType == MessageType.Replies && "active"}
345 value={MessageType.Replies}
346 checked={this.state.messageType == MessageType.Replies}
347 onChange={linkEvent(this, this.handleMessageTypeChange)}
352 className={`btn btn-outline-secondary pointer
353 ${this.state.messageType == MessageType.Mentions && "active"}
358 value={MessageType.Mentions}
359 checked={this.state.messageType == MessageType.Mentions}
360 onChange={linkEvent(this, this.handleMessageTypeChange)}
365 className={`btn btn-outline-secondary pointer
366 ${this.state.messageType == MessageType.Messages && "active"}
371 value={MessageType.Messages}
372 checked={this.state.messageType == MessageType.Messages}
373 onChange={linkEvent(this, this.handleMessageTypeChange)}
383 <div className="mb-2">
384 <span className="mr-3">{this.unreadOrAllRadios()}</span>
385 <span className="mr-3">{this.messageTypeRadios()}</span>
387 sort={this.state.sort}
388 onChange={this.handleSortChange}
394 replyToReplyType(r: CommentReplyView): ReplyType {
396 id: r.comment_reply.id,
397 type_: ReplyEnum.Reply,
399 published: r.comment.published,
403 mentionToReplyType(r: PersonMentionView): ReplyType {
405 id: r.person_mention.id,
406 type_: ReplyEnum.Mention,
408 published: r.comment.published,
412 messageToReplyType(r: PrivateMessageView): ReplyType {
414 id: r.private_message.id,
415 type_: ReplyEnum.Message,
417 published: r.private_message.published,
421 buildCombined(): ReplyType[] {
422 const replies: ReplyType[] =
423 this.state.repliesRes.state == "success"
424 ? this.state.repliesRes.data.replies.map(this.replyToReplyType)
426 const mentions: ReplyType[] =
427 this.state.mentionsRes.state == "success"
428 ? this.state.mentionsRes.data.mentions.map(this.mentionToReplyType)
430 const messages: ReplyType[] =
431 this.state.messagesRes.state == "success"
432 ? this.state.messagesRes.data.private_messages.map(
433 this.messageToReplyType
437 return [...replies, ...mentions, ...messages].sort((a, b) =>
438 b.published.localeCompare(a.published)
442 renderReplyType(i: ReplyType) {
444 case ReplyEnum.Reply:
449 { comment_view: i.view as CommentView, children: [], depth: 0 },
451 viewType={CommentViewType.Flat}
452 finished={this.state.finished}
457 enableDownvotes={enableDownvotes(this.state.siteRes)}
458 allLanguages={this.state.siteRes.all_languages}
459 siteLanguages={this.state.siteRes.discussion_languages}
460 onSaveComment={this.handleSaveComment}
461 onBlockPerson={this.handleBlockPerson}
462 onDeleteComment={this.handleDeleteComment}
463 onRemoveComment={this.handleRemoveComment}
464 onCommentVote={this.handleCommentVote}
465 onCommentReport={this.handleCommentReport}
466 onDistinguishComment={this.handleDistinguishComment}
467 onAddModToCommunity={this.handleAddModToCommunity}
468 onAddAdmin={this.handleAddAdmin}
469 onTransferCommunity={this.handleTransferCommunity}
470 onPurgeComment={this.handlePurgeComment}
471 onPurgePerson={this.handlePurgePerson}
472 onCommentReplyRead={this.handleCommentReplyRead}
473 onPersonMentionRead={this.handlePersonMentionRead}
474 onBanPersonFromCommunity={this.handleBanFromCommunity}
475 onBanPerson={this.handleBanPerson}
476 onCreateComment={this.handleCreateComment}
477 onEditComment={this.handleEditComment}
480 case ReplyEnum.Mention:
486 comment_view: i.view as PersonMentionView,
491 finished={this.state.finished}
492 viewType={CommentViewType.Flat}
497 enableDownvotes={enableDownvotes(this.state.siteRes)}
498 allLanguages={this.state.siteRes.all_languages}
499 siteLanguages={this.state.siteRes.discussion_languages}
500 onSaveComment={this.handleSaveComment}
501 onBlockPerson={this.handleBlockPerson}
502 onDeleteComment={this.handleDeleteComment}
503 onRemoveComment={this.handleRemoveComment}
504 onCommentVote={this.handleCommentVote}
505 onCommentReport={this.handleCommentReport}
506 onDistinguishComment={this.handleDistinguishComment}
507 onAddModToCommunity={this.handleAddModToCommunity}
508 onAddAdmin={this.handleAddAdmin}
509 onTransferCommunity={this.handleTransferCommunity}
510 onPurgeComment={this.handlePurgeComment}
511 onPurgePerson={this.handlePurgePerson}
512 onCommentReplyRead={this.handleCommentReplyRead}
513 onPersonMentionRead={this.handlePersonMentionRead}
514 onBanPersonFromCommunity={this.handleBanFromCommunity}
515 onBanPerson={this.handleBanPerson}
516 onCreateComment={this.handleCreateComment}
517 onEditComment={this.handleEditComment}
520 case ReplyEnum.Message:
524 private_message_view={i.view as PrivateMessageView}
525 onDelete={this.handleDeleteMessage}
526 onMarkRead={this.handleMarkMessageAsRead}
527 onReport={this.handleMessageReport}
528 onCreate={this.handleCreateMessage}
529 onEdit={this.handleEditMessage}
539 this.state.repliesRes.state == "loading" ||
540 this.state.mentionsRes.state == "loading" ||
541 this.state.messagesRes.state == "loading"
550 <div>{this.buildCombined().map(r => this.renderReplyType(r))}</div>
556 switch (this.state.repliesRes.state) {
564 const replies = this.state.repliesRes.data.replies;
568 nodes={commentsToFlatNodes(replies)}
569 viewType={CommentViewType.Flat}
570 finished={this.state.finished}
575 enableDownvotes={enableDownvotes(this.state.siteRes)}
576 allLanguages={this.state.siteRes.all_languages}
577 siteLanguages={this.state.siteRes.discussion_languages}
578 onSaveComment={this.handleSaveComment}
579 onBlockPerson={this.handleBlockPerson}
580 onDeleteComment={this.handleDeleteComment}
581 onRemoveComment={this.handleRemoveComment}
582 onCommentVote={this.handleCommentVote}
583 onCommentReport={this.handleCommentReport}
584 onDistinguishComment={this.handleDistinguishComment}
585 onAddModToCommunity={this.handleAddModToCommunity}
586 onAddAdmin={this.handleAddAdmin}
587 onTransferCommunity={this.handleTransferCommunity}
588 onPurgeComment={this.handlePurgeComment}
589 onPurgePerson={this.handlePurgePerson}
590 onCommentReplyRead={this.handleCommentReplyRead}
591 onPersonMentionRead={this.handlePersonMentionRead}
592 onBanPersonFromCommunity={this.handleBanFromCommunity}
593 onBanPerson={this.handleBanPerson}
594 onCreateComment={this.handleCreateComment}
595 onEditComment={this.handleEditComment}
604 switch (this.state.mentionsRes.state) {
612 const mentions = this.state.mentionsRes.data.mentions;
615 {mentions.map(umv => (
617 key={umv.person_mention.id}
618 nodes={[{ comment_view: umv, children: [], depth: 0 }]}
619 viewType={CommentViewType.Flat}
620 finished={this.state.finished}
625 enableDownvotes={enableDownvotes(this.state.siteRes)}
626 allLanguages={this.state.siteRes.all_languages}
627 siteLanguages={this.state.siteRes.discussion_languages}
628 onSaveComment={this.handleSaveComment}
629 onBlockPerson={this.handleBlockPerson}
630 onDeleteComment={this.handleDeleteComment}
631 onRemoveComment={this.handleRemoveComment}
632 onCommentVote={this.handleCommentVote}
633 onCommentReport={this.handleCommentReport}
634 onDistinguishComment={this.handleDistinguishComment}
635 onAddModToCommunity={this.handleAddModToCommunity}
636 onAddAdmin={this.handleAddAdmin}
637 onTransferCommunity={this.handleTransferCommunity}
638 onPurgeComment={this.handlePurgeComment}
639 onPurgePerson={this.handlePurgePerson}
640 onCommentReplyRead={this.handleCommentReplyRead}
641 onPersonMentionRead={this.handlePersonMentionRead}
642 onBanPersonFromCommunity={this.handleBanFromCommunity}
643 onBanPerson={this.handleBanPerson}
644 onCreateComment={this.handleCreateComment}
645 onEditComment={this.handleEditComment}
655 switch (this.state.messagesRes.state) {
663 const messages = this.state.messagesRes.data.private_messages;
666 {messages.map(pmv => (
668 key={pmv.private_message.id}
669 private_message_view={pmv}
670 onDelete={this.handleDeleteMessage}
671 onMarkRead={this.handleMarkMessageAsRead}
672 onReport={this.handleMessageReport}
673 onCreate={this.handleCreateMessage}
674 onEdit={this.handleEditMessage}
683 async handlePageChange(page: number) {
684 this.setState({ page });
685 await this.refetch();
688 async handleUnreadOrAllChange(i: Inbox, event: any) {
689 i.setState({ unreadOrAll: Number(event.target.value), page: 1 });
693 async handleMessageTypeChange(i: Inbox, event: any) {
694 i.setState({ messageType: Number(event.target.value), page: 1 });
698 static async fetchInitialData({
701 }: InitialFetchRequest): Promise<InboxData> {
702 const sort: CommentSortType = "New";
705 personMentionsResponse: auth
706 ? await client.getPersonMentions({
713 : { state: "empty" },
714 privateMessagesResponse: auth
715 ? await client.getPrivateMessages({
721 : { state: "empty" },
722 repliesResponse: auth
723 ? await client.getReplies({
730 : { state: "empty" },
735 const sort = this.state.sort;
736 const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread;
737 const page = this.state.page;
738 const limit = fetchLimit;
739 const auth = myAuthRequired();
741 this.setState({ repliesRes: { state: "loading" } });
743 repliesRes: await HttpService.client.getReplies({
752 this.setState({ mentionsRes: { state: "loading" } });
754 mentionsRes: await HttpService.client.getPersonMentions({
763 this.setState({ messagesRes: { state: "loading" } });
765 messagesRes: await HttpService.client.getPrivateMessages({
774 async handleSortChange(val: CommentSortType) {
775 this.setState({ sort: val, page: 1 });
776 await this.refetch();
779 async handleMarkAllAsRead(i: Inbox) {
780 i.setState({ markAllAsReadRes: { state: "loading" } });
783 markAllAsReadRes: await HttpService.client.markAllAsRead({
784 auth: myAuthRequired(),
788 if (i.state.markAllAsReadRes.state == "success") {
790 repliesRes: { state: "empty" },
791 mentionsRes: { state: "empty" },
792 messagesRes: { state: "empty" },
797 async handleAddModToCommunity(form: AddModToCommunity) {
798 // TODO not sure what to do here
799 HttpService.client.addModToCommunity(form);
802 async handlePurgePerson(form: PurgePerson) {
803 const purgePersonRes = await HttpService.client.purgePerson(form);
804 this.purgeItem(purgePersonRes);
807 async handlePurgeComment(form: PurgeComment) {
808 const purgeCommentRes = await HttpService.client.purgeComment(form);
809 this.purgeItem(purgeCommentRes);
812 async handlePurgePost(form: PurgePost) {
813 const purgeRes = await HttpService.client.purgePost(form);
814 this.purgeItem(purgeRes);
817 async handleBlockPerson(form: BlockPerson) {
818 const blockPersonRes = await HttpService.client.blockPerson(form);
819 if (blockPersonRes.state == "success") {
820 updatePersonBlock(blockPersonRes.data);
824 async handleCreateComment(form: CreateComment) {
825 const res = await HttpService.client.createComment(form);
827 if (res.state === "success") {
828 toast(i18n.t("reply_sent"));
829 this.findAndUpdateComment(res);
835 async handleEditComment(form: EditComment) {
836 const res = await HttpService.client.editComment(form);
838 if (res.state === "success") {
839 toast(i18n.t("edit"));
840 this.findAndUpdateComment(res);
841 } else if (res.state === "failed") {
842 toast(res.msg, "danger");
848 async handleDeleteComment(form: DeleteComment) {
849 const res = await HttpService.client.deleteComment(form);
850 if (res.state == "success") {
851 toast(i18n.t("deleted"));
852 this.findAndUpdateComment(res);
856 async handleRemoveComment(form: RemoveComment) {
857 const res = await HttpService.client.removeComment(form);
858 if (res.state == "success") {
859 toast(i18n.t("remove_comment"));
860 this.findAndUpdateComment(res);
864 async handleSaveComment(form: SaveComment) {
865 const res = await HttpService.client.saveComment(form);
866 this.findAndUpdateComment(res);
869 async handleCommentVote(form: CreateCommentLike) {
870 const res = await HttpService.client.likeComment(form);
871 this.findAndUpdateComment(res);
874 async handleCommentReport(form: CreateCommentReport) {
875 const reportRes = await HttpService.client.createCommentReport(form);
876 this.reportToast(reportRes);
879 async handleDistinguishComment(form: DistinguishComment) {
880 const res = await HttpService.client.distinguishComment(form);
881 this.findAndUpdateComment(res);
884 async handleAddAdmin(form: AddAdmin) {
885 const addAdminRes = await HttpService.client.addAdmin(form);
887 if (addAdminRes.state === "success") {
888 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
892 async handleTransferCommunity(form: TransferCommunity) {
893 await HttpService.client.transferCommunity(form);
894 toast(i18n.t("transfer_community"));
897 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
898 const res = await HttpService.client.markCommentReplyAsRead(form);
899 this.findAndUpdateCommentReply(res);
902 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
903 const res = await HttpService.client.markPersonMentionAsRead(form);
904 this.findAndUpdateMention(res);
907 async handleBanFromCommunity(form: BanFromCommunity) {
908 const banRes = await HttpService.client.banFromCommunity(form);
909 this.updateBanFromCommunity(banRes);
912 async handleBanPerson(form: BanPerson) {
913 const banRes = await HttpService.client.banPerson(form);
914 this.updateBan(banRes);
917 async handleDeleteMessage(form: DeletePrivateMessage) {
918 const res = await HttpService.client.deletePrivateMessage(form);
919 this.findAndUpdateMessage(res);
922 async handleEditMessage(form: EditPrivateMessage) {
923 const res = await HttpService.client.editPrivateMessage(form);
924 this.findAndUpdateMessage(res);
927 async handleMarkMessageAsRead(form: MarkPrivateMessageAsRead) {
928 const res = await HttpService.client.markPrivateMessageAsRead(form);
929 this.findAndUpdateMessage(res);
932 async handleMessageReport(form: CreatePrivateMessageReport) {
933 const res = await HttpService.client.createPrivateMessageReport(form);
934 this.reportToast(res);
937 async handleCreateMessage(form: CreatePrivateMessage) {
938 const res = await HttpService.client.createPrivateMessage(form);
940 if (s.messagesRes.state == "success" && res.state == "success") {
941 s.messagesRes.data.private_messages.unshift(
942 res.data.private_message_view
950 findAndUpdateMessage(res: RequestState<PrivateMessageResponse>) {
952 if (s.messagesRes.state === "success" && res.state === "success") {
953 s.messagesRes.data.private_messages = editPrivateMessage(
954 res.data.private_message_view,
955 s.messagesRes.data.private_messages
962 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
963 // Maybe not necessary
964 if (banRes.state == "success") {
966 if (s.repliesRes.state == "success") {
967 s.repliesRes.data.replies
968 .filter(c => c.creator.id == banRes.data.person_view.person.id)
970 c => (c.creator_banned_from_community = banRes.data.banned)
973 if (s.mentionsRes.state == "success") {
974 s.mentionsRes.data.mentions
975 .filter(c => c.creator.id == banRes.data.person_view.person.id)
977 c => (c.creator_banned_from_community = banRes.data.banned)
985 updateBan(banRes: RequestState<BanPersonResponse>) {
986 // Maybe not necessary
987 if (banRes.state == "success") {
989 if (s.repliesRes.state == "success") {
990 s.repliesRes.data.replies
991 .filter(c => c.creator.id == banRes.data.person_view.person.id)
992 .forEach(c => (c.creator.banned = banRes.data.banned));
994 if (s.mentionsRes.state == "success") {
995 s.mentionsRes.data.mentions
996 .filter(c => c.creator.id == banRes.data.person_view.person.id)
997 .forEach(c => (c.creator.banned = banRes.data.banned));
1004 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1005 if (purgeRes.state == "success") {
1006 toast(i18n.t("purge_success"));
1007 this.context.router.history.push(`/`);
1012 res: RequestState<PrivateMessageReportResponse | CommentReportResponse>
1014 if (res.state == "success") {
1015 toast(i18n.t("report_created"));
1019 // A weird case, since you have only replies and mentions, not comment responses
1020 findAndUpdateComment(res: RequestState<CommentResponse>) {
1021 if (res.state == "success") {
1022 this.setState(s => {
1023 if (s.repliesRes.state == "success") {
1024 s.repliesRes.data.replies = editWith(
1025 res.data.comment_view,
1026 s.repliesRes.data.replies
1029 if (s.mentionsRes.state == "success") {
1030 s.mentionsRes.data.mentions = editWith(
1031 res.data.comment_view,
1032 s.mentionsRes.data.mentions
1035 // Set finished for the parent
1037 getCommentParentId(res.data.comment_view.comment) ?? 0,
1045 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1046 this.setState(s => {
1047 if (s.repliesRes.state == "success" && res.state == "success") {
1048 s.repliesRes.data.replies = editCommentReply(
1049 res.data.comment_reply_view,
1050 s.repliesRes.data.replies
1057 findAndUpdateMention(res: RequestState<PersonMentionResponse>) {
1058 this.setState(s => {
1059 if (s.mentionsRes.state == "success" && res.state == "success") {
1060 s.mentionsRes.data.mentions = editMention(
1061 res.data.person_mention_view,
1062 s.mentionsRes.data.mentions