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="inbox 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="ms-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 className="btn-check"
296 value={UnreadOrAll.Unread}
297 checked={this.state.unreadOrAll == UnreadOrAll.Unread}
298 onChange={linkEvent(this, this.handleUnreadOrAllChange)}
303 className={`btn btn-outline-secondary pointer
304 ${this.state.unreadOrAll == UnreadOrAll.All && "active"}
309 className="btn-check"
310 value={UnreadOrAll.All}
311 checked={this.state.unreadOrAll == UnreadOrAll.All}
312 onChange={linkEvent(this, this.handleUnreadOrAllChange)}
320 messageTypeRadios() {
322 <div className="btn-group btn-group-toggle flex-wrap mb-2">
324 className={`btn btn-outline-secondary pointer
325 ${this.state.messageType == MessageType.All && "active"}
330 className="btn-check"
331 value={MessageType.All}
332 checked={this.state.messageType == MessageType.All}
333 onChange={linkEvent(this, this.handleMessageTypeChange)}
338 className={`btn btn-outline-secondary pointer
339 ${this.state.messageType == MessageType.Replies && "active"}
344 className="btn-check"
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 className="btn-check"
359 value={MessageType.Mentions}
360 checked={this.state.messageType == MessageType.Mentions}
361 onChange={linkEvent(this, this.handleMessageTypeChange)}
366 className={`btn btn-outline-secondary pointer
367 ${this.state.messageType == MessageType.Messages && "active"}
372 className="btn-check"
373 value={MessageType.Messages}
374 checked={this.state.messageType == MessageType.Messages}
375 onChange={linkEvent(this, this.handleMessageTypeChange)}
385 <div className="mb-2">
386 <span className="me-3">{this.unreadOrAllRadios()}</span>
387 <span className="me-3">{this.messageTypeRadios()}</span>
389 sort={this.state.sort}
390 onChange={this.handleSortChange}
396 replyToReplyType(r: CommentReplyView): ReplyType {
398 id: r.comment_reply.id,
399 type_: ReplyEnum.Reply,
401 published: r.comment.published,
405 mentionToReplyType(r: PersonMentionView): ReplyType {
407 id: r.person_mention.id,
408 type_: ReplyEnum.Mention,
410 published: r.comment.published,
414 messageToReplyType(r: PrivateMessageView): ReplyType {
416 id: r.private_message.id,
417 type_: ReplyEnum.Message,
419 published: r.private_message.published,
423 buildCombined(): ReplyType[] {
424 const replies: ReplyType[] =
425 this.state.repliesRes.state == "success"
426 ? this.state.repliesRes.data.replies.map(this.replyToReplyType)
428 const mentions: ReplyType[] =
429 this.state.mentionsRes.state == "success"
430 ? this.state.mentionsRes.data.mentions.map(this.mentionToReplyType)
432 const messages: ReplyType[] =
433 this.state.messagesRes.state == "success"
434 ? this.state.messagesRes.data.private_messages.map(
435 this.messageToReplyType
439 return [...replies, ...mentions, ...messages].sort((a, b) =>
440 b.published.localeCompare(a.published)
444 renderReplyType(i: ReplyType) {
446 case ReplyEnum.Reply:
451 { comment_view: i.view as CommentView, children: [], depth: 0 },
453 viewType={CommentViewType.Flat}
454 finished={this.state.finished}
459 enableDownvotes={enableDownvotes(this.state.siteRes)}
460 allLanguages={this.state.siteRes.all_languages}
461 siteLanguages={this.state.siteRes.discussion_languages}
462 onSaveComment={this.handleSaveComment}
463 onBlockPerson={this.handleBlockPerson}
464 onDeleteComment={this.handleDeleteComment}
465 onRemoveComment={this.handleRemoveComment}
466 onCommentVote={this.handleCommentVote}
467 onCommentReport={this.handleCommentReport}
468 onDistinguishComment={this.handleDistinguishComment}
469 onAddModToCommunity={this.handleAddModToCommunity}
470 onAddAdmin={this.handleAddAdmin}
471 onTransferCommunity={this.handleTransferCommunity}
472 onPurgeComment={this.handlePurgeComment}
473 onPurgePerson={this.handlePurgePerson}
474 onCommentReplyRead={this.handleCommentReplyRead}
475 onPersonMentionRead={this.handlePersonMentionRead}
476 onBanPersonFromCommunity={this.handleBanFromCommunity}
477 onBanPerson={this.handleBanPerson}
478 onCreateComment={this.handleCreateComment}
479 onEditComment={this.handleEditComment}
482 case ReplyEnum.Mention:
488 comment_view: i.view as PersonMentionView,
493 finished={this.state.finished}
494 viewType={CommentViewType.Flat}
499 enableDownvotes={enableDownvotes(this.state.siteRes)}
500 allLanguages={this.state.siteRes.all_languages}
501 siteLanguages={this.state.siteRes.discussion_languages}
502 onSaveComment={this.handleSaveComment}
503 onBlockPerson={this.handleBlockPerson}
504 onDeleteComment={this.handleDeleteComment}
505 onRemoveComment={this.handleRemoveComment}
506 onCommentVote={this.handleCommentVote}
507 onCommentReport={this.handleCommentReport}
508 onDistinguishComment={this.handleDistinguishComment}
509 onAddModToCommunity={this.handleAddModToCommunity}
510 onAddAdmin={this.handleAddAdmin}
511 onTransferCommunity={this.handleTransferCommunity}
512 onPurgeComment={this.handlePurgeComment}
513 onPurgePerson={this.handlePurgePerson}
514 onCommentReplyRead={this.handleCommentReplyRead}
515 onPersonMentionRead={this.handlePersonMentionRead}
516 onBanPersonFromCommunity={this.handleBanFromCommunity}
517 onBanPerson={this.handleBanPerson}
518 onCreateComment={this.handleCreateComment}
519 onEditComment={this.handleEditComment}
522 case ReplyEnum.Message:
526 private_message_view={i.view as PrivateMessageView}
527 onDelete={this.handleDeleteMessage}
528 onMarkRead={this.handleMarkMessageAsRead}
529 onReport={this.handleMessageReport}
530 onCreate={this.handleCreateMessage}
531 onEdit={this.handleEditMessage}
541 this.state.repliesRes.state == "loading" ||
542 this.state.mentionsRes.state == "loading" ||
543 this.state.messagesRes.state == "loading"
552 <div>{this.buildCombined().map(r => this.renderReplyType(r))}</div>
558 switch (this.state.repliesRes.state) {
566 const replies = this.state.repliesRes.data.replies;
570 nodes={commentsToFlatNodes(replies)}
571 viewType={CommentViewType.Flat}
572 finished={this.state.finished}
577 enableDownvotes={enableDownvotes(this.state.siteRes)}
578 allLanguages={this.state.siteRes.all_languages}
579 siteLanguages={this.state.siteRes.discussion_languages}
580 onSaveComment={this.handleSaveComment}
581 onBlockPerson={this.handleBlockPerson}
582 onDeleteComment={this.handleDeleteComment}
583 onRemoveComment={this.handleRemoveComment}
584 onCommentVote={this.handleCommentVote}
585 onCommentReport={this.handleCommentReport}
586 onDistinguishComment={this.handleDistinguishComment}
587 onAddModToCommunity={this.handleAddModToCommunity}
588 onAddAdmin={this.handleAddAdmin}
589 onTransferCommunity={this.handleTransferCommunity}
590 onPurgeComment={this.handlePurgeComment}
591 onPurgePerson={this.handlePurgePerson}
592 onCommentReplyRead={this.handleCommentReplyRead}
593 onPersonMentionRead={this.handlePersonMentionRead}
594 onBanPersonFromCommunity={this.handleBanFromCommunity}
595 onBanPerson={this.handleBanPerson}
596 onCreateComment={this.handleCreateComment}
597 onEditComment={this.handleEditComment}
606 switch (this.state.mentionsRes.state) {
614 const mentions = this.state.mentionsRes.data.mentions;
617 {mentions.map(umv => (
619 key={umv.person_mention.id}
620 nodes={[{ comment_view: umv, children: [], depth: 0 }]}
621 viewType={CommentViewType.Flat}
622 finished={this.state.finished}
627 enableDownvotes={enableDownvotes(this.state.siteRes)}
628 allLanguages={this.state.siteRes.all_languages}
629 siteLanguages={this.state.siteRes.discussion_languages}
630 onSaveComment={this.handleSaveComment}
631 onBlockPerson={this.handleBlockPerson}
632 onDeleteComment={this.handleDeleteComment}
633 onRemoveComment={this.handleRemoveComment}
634 onCommentVote={this.handleCommentVote}
635 onCommentReport={this.handleCommentReport}
636 onDistinguishComment={this.handleDistinguishComment}
637 onAddModToCommunity={this.handleAddModToCommunity}
638 onAddAdmin={this.handleAddAdmin}
639 onTransferCommunity={this.handleTransferCommunity}
640 onPurgeComment={this.handlePurgeComment}
641 onPurgePerson={this.handlePurgePerson}
642 onCommentReplyRead={this.handleCommentReplyRead}
643 onPersonMentionRead={this.handlePersonMentionRead}
644 onBanPersonFromCommunity={this.handleBanFromCommunity}
645 onBanPerson={this.handleBanPerson}
646 onCreateComment={this.handleCreateComment}
647 onEditComment={this.handleEditComment}
657 switch (this.state.messagesRes.state) {
665 const messages = this.state.messagesRes.data.private_messages;
668 {messages.map(pmv => (
670 key={pmv.private_message.id}
671 private_message_view={pmv}
672 onDelete={this.handleDeleteMessage}
673 onMarkRead={this.handleMarkMessageAsRead}
674 onReport={this.handleMessageReport}
675 onCreate={this.handleCreateMessage}
676 onEdit={this.handleEditMessage}
685 async handlePageChange(page: number) {
686 this.setState({ page });
687 await this.refetch();
690 async handleUnreadOrAllChange(i: Inbox, event: any) {
691 i.setState({ unreadOrAll: Number(event.target.value), page: 1 });
695 async handleMessageTypeChange(i: Inbox, event: any) {
696 i.setState({ messageType: Number(event.target.value), page: 1 });
700 static async fetchInitialData({
703 }: InitialFetchRequest): Promise<InboxData> {
704 const sort: CommentSortType = "New";
708 ? await client.getPersonMentions({
715 : { state: "empty" },
717 ? await client.getPrivateMessages({
723 : { state: "empty" },
725 ? await client.getReplies({
732 : { state: "empty" },
737 const sort = this.state.sort;
738 const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread;
739 const page = this.state.page;
740 const limit = fetchLimit;
741 const auth = myAuthRequired();
743 this.setState({ repliesRes: { state: "loading" } });
745 repliesRes: await HttpService.client.getReplies({
754 this.setState({ mentionsRes: { state: "loading" } });
756 mentionsRes: await HttpService.client.getPersonMentions({
765 this.setState({ messagesRes: { state: "loading" } });
767 messagesRes: await HttpService.client.getPrivateMessages({
776 async handleSortChange(val: CommentSortType) {
777 this.setState({ sort: val, page: 1 });
778 await this.refetch();
781 async handleMarkAllAsRead(i: Inbox) {
782 i.setState({ markAllAsReadRes: { state: "loading" } });
785 markAllAsReadRes: await HttpService.client.markAllAsRead({
786 auth: myAuthRequired(),
790 if (i.state.markAllAsReadRes.state == "success") {
792 repliesRes: { state: "empty" },
793 mentionsRes: { state: "empty" },
794 messagesRes: { state: "empty" },
799 async handleAddModToCommunity(form: AddModToCommunity) {
800 // TODO not sure what to do here
801 HttpService.client.addModToCommunity(form);
804 async handlePurgePerson(form: PurgePerson) {
805 const purgePersonRes = await HttpService.client.purgePerson(form);
806 this.purgeItem(purgePersonRes);
809 async handlePurgeComment(form: PurgeComment) {
810 const purgeCommentRes = await HttpService.client.purgeComment(form);
811 this.purgeItem(purgeCommentRes);
814 async handlePurgePost(form: PurgePost) {
815 const purgeRes = await HttpService.client.purgePost(form);
816 this.purgeItem(purgeRes);
819 async handleBlockPerson(form: BlockPerson) {
820 const blockPersonRes = await HttpService.client.blockPerson(form);
821 if (blockPersonRes.state == "success") {
822 updatePersonBlock(blockPersonRes.data);
826 async handleCreateComment(form: CreateComment) {
827 const res = await HttpService.client.createComment(form);
829 if (res.state === "success") {
830 toast(i18n.t("reply_sent"));
831 this.findAndUpdateComment(res);
837 async handleEditComment(form: EditComment) {
838 const res = await HttpService.client.editComment(form);
840 if (res.state === "success") {
841 toast(i18n.t("edit"));
842 this.findAndUpdateComment(res);
843 } else if (res.state === "failed") {
844 toast(res.msg, "danger");
850 async handleDeleteComment(form: DeleteComment) {
851 const res = await HttpService.client.deleteComment(form);
852 if (res.state == "success") {
853 toast(i18n.t("deleted"));
854 this.findAndUpdateComment(res);
858 async handleRemoveComment(form: RemoveComment) {
859 const res = await HttpService.client.removeComment(form);
860 if (res.state == "success") {
861 toast(i18n.t("remove_comment"));
862 this.findAndUpdateComment(res);
866 async handleSaveComment(form: SaveComment) {
867 const res = await HttpService.client.saveComment(form);
868 this.findAndUpdateComment(res);
871 async handleCommentVote(form: CreateCommentLike) {
872 const res = await HttpService.client.likeComment(form);
873 this.findAndUpdateComment(res);
876 async handleCommentReport(form: CreateCommentReport) {
877 const reportRes = await HttpService.client.createCommentReport(form);
878 this.reportToast(reportRes);
881 async handleDistinguishComment(form: DistinguishComment) {
882 const res = await HttpService.client.distinguishComment(form);
883 this.findAndUpdateComment(res);
886 async handleAddAdmin(form: AddAdmin) {
887 const addAdminRes = await HttpService.client.addAdmin(form);
889 if (addAdminRes.state === "success") {
890 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
894 async handleTransferCommunity(form: TransferCommunity) {
895 await HttpService.client.transferCommunity(form);
896 toast(i18n.t("transfer_community"));
899 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
900 const res = await HttpService.client.markCommentReplyAsRead(form);
901 this.findAndUpdateCommentReply(res);
904 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
905 const res = await HttpService.client.markPersonMentionAsRead(form);
906 this.findAndUpdateMention(res);
909 async handleBanFromCommunity(form: BanFromCommunity) {
910 const banRes = await HttpService.client.banFromCommunity(form);
911 this.updateBanFromCommunity(banRes);
914 async handleBanPerson(form: BanPerson) {
915 const banRes = await HttpService.client.banPerson(form);
916 this.updateBan(banRes);
919 async handleDeleteMessage(form: DeletePrivateMessage) {
920 const res = await HttpService.client.deletePrivateMessage(form);
921 this.findAndUpdateMessage(res);
924 async handleEditMessage(form: EditPrivateMessage) {
925 const res = await HttpService.client.editPrivateMessage(form);
926 this.findAndUpdateMessage(res);
929 async handleMarkMessageAsRead(form: MarkPrivateMessageAsRead) {
930 const res = await HttpService.client.markPrivateMessageAsRead(form);
931 this.findAndUpdateMessage(res);
934 async handleMessageReport(form: CreatePrivateMessageReport) {
935 const res = await HttpService.client.createPrivateMessageReport(form);
936 this.reportToast(res);
939 async handleCreateMessage(form: CreatePrivateMessage) {
940 const res = await HttpService.client.createPrivateMessage(form);
942 if (s.messagesRes.state == "success" && res.state == "success") {
943 s.messagesRes.data.private_messages.unshift(
944 res.data.private_message_view
952 findAndUpdateMessage(res: RequestState<PrivateMessageResponse>) {
954 if (s.messagesRes.state === "success" && res.state === "success") {
955 s.messagesRes.data.private_messages = editPrivateMessage(
956 res.data.private_message_view,
957 s.messagesRes.data.private_messages
964 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
965 // Maybe not necessary
966 if (banRes.state == "success") {
968 if (s.repliesRes.state == "success") {
969 s.repliesRes.data.replies
970 .filter(c => c.creator.id == banRes.data.person_view.person.id)
972 c => (c.creator_banned_from_community = banRes.data.banned)
975 if (s.mentionsRes.state == "success") {
976 s.mentionsRes.data.mentions
977 .filter(c => c.creator.id == banRes.data.person_view.person.id)
979 c => (c.creator_banned_from_community = banRes.data.banned)
987 updateBan(banRes: RequestState<BanPersonResponse>) {
988 // Maybe not necessary
989 if (banRes.state == "success") {
991 if (s.repliesRes.state == "success") {
992 s.repliesRes.data.replies
993 .filter(c => c.creator.id == banRes.data.person_view.person.id)
994 .forEach(c => (c.creator.banned = banRes.data.banned));
996 if (s.mentionsRes.state == "success") {
997 s.mentionsRes.data.mentions
998 .filter(c => c.creator.id == banRes.data.person_view.person.id)
999 .forEach(c => (c.creator.banned = banRes.data.banned));
1006 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1007 if (purgeRes.state == "success") {
1008 toast(i18n.t("purge_success"));
1009 this.context.router.history.push(`/`);
1014 res: RequestState<PrivateMessageReportResponse | CommentReportResponse>
1016 if (res.state == "success") {
1017 toast(i18n.t("report_created"));
1021 // A weird case, since you have only replies and mentions, not comment responses
1022 findAndUpdateComment(res: RequestState<CommentResponse>) {
1023 if (res.state == "success") {
1024 this.setState(s => {
1025 if (s.repliesRes.state == "success") {
1026 s.repliesRes.data.replies = editWith(
1027 res.data.comment_view,
1028 s.repliesRes.data.replies
1031 if (s.mentionsRes.state == "success") {
1032 s.mentionsRes.data.mentions = editWith(
1033 res.data.comment_view,
1034 s.mentionsRes.data.mentions
1037 // Set finished for the parent
1039 getCommentParentId(res.data.comment_view.comment) ?? 0,
1047 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1048 this.setState(s => {
1049 if (s.repliesRes.state == "success" && res.state == "success") {
1050 s.repliesRes.data.replies = editCommentReply(
1051 res.data.comment_reply_view,
1052 s.repliesRes.data.replies
1059 findAndUpdateMention(res: RequestState<PersonMentionResponse>) {
1060 this.setState(s => {
1061 if (s.mentionsRes.state == "success" && res.state == "success") {
1062 s.mentionsRes.data.mentions = editMention(
1063 res.data.person_mention_view,
1064 s.mentionsRes.data.mentions