1 import { NoOptionI18nKeys } from "i18next";
2 import { Component, linkEvent, MouseEventHandler } from "inferno";
3 import { T } from "inferno-i18next-dess";
4 import { Link } from "inferno-router";
9 BanFromCommunityResponse,
33 ListCommunitiesResponse,
36 MarkCommentReplyAsRead,
37 MarkPersonMentionAsRead,
49 } from "lemmy-js-client";
50 import { i18n } from "../../i18next";
55 } from "../../interfaces";
56 import { UserService } from "../../services";
57 import { FirstLoadService } from "../../services/FirstLoadService";
58 import { HttpService, RequestState } from "../../services/HttpService";
76 postToCommentSortType,
79 restoreScrollPosition,
89 import { CommentNodes } from "../comment/comment-nodes";
90 import { DataTypeSelect } from "../common/data-type-select";
91 import { HtmlTags } from "../common/html-tags";
92 import { Icon, Spinner } from "../common/icon";
93 import { ListingTypeSelect } from "../common/listing-type-select";
94 import { Paginator } from "../common/paginator";
95 import { SortSelect } from "../common/sort-select";
96 import { CommunityLink } from "../community/community-link";
97 import { PostListings } from "../post/post-listings";
98 import { SiteSidebar } from "./site-sidebar";
100 interface HomeState {
101 postsRes: RequestState<GetPostsResponse>;
102 commentsRes: RequestState<GetCommentsResponse>;
103 trendingCommunitiesRes: RequestState<ListCommunitiesResponse>;
104 showSubscribedMobile: boolean;
105 showTrendingMobile: boolean;
106 showSidebarMobile: boolean;
107 subscribedCollapsed: boolean;
109 siteRes: GetSiteResponse;
110 finished: Map<CommentId, boolean | undefined>;
111 isIsomorphic: boolean;
114 interface HomeProps {
115 listingType: ListingType;
121 type HomeData = RouteDataResponse<{
122 postsRes: GetPostsResponse;
123 commentsRes: GetCommentsResponse;
124 trendingCommunitiesRes: ListCommunitiesResponse;
127 function getRss(listingType: ListingType) {
128 const { sort } = getHomeQueryParams();
129 const auth = myAuth();
131 let rss: string | undefined = undefined;
133 switch (listingType) {
135 rss = `/feeds/all.xml?sort=${sort}`;
139 rss = `/feeds/local.xml?sort=${sort}`;
143 rss = auth ? `/feeds/front/${auth}.xml?sort=${sort}` : undefined;
151 <a href={rss} rel={relTags} title="RSS">
152 <Icon icon="rss" classes="text-muted small" />
154 <link rel="alternate" type="application/atom+xml" href={rss} />
160 function getDataTypeFromQuery(type?: string): DataType {
161 return type ? DataType[type] : DataType.Post;
164 function getListingTypeFromQuery(type?: string): ListingType {
165 const myListingType =
166 UserService.Instance.myUserInfo?.local_user_view?.local_user
167 ?.default_listing_type;
169 return (type ? (type as ListingType) : myListingType) ?? "Local";
172 function getSortTypeFromQuery(type?: string): SortType {
174 UserService.Instance.myUserInfo?.local_user_view?.local_user
177 return (type ? (type as SortType) : mySortType) ?? "Active";
180 const getHomeQueryParams = () =>
181 getQueryParams<HomeProps>({
182 sort: getSortTypeFromQuery,
183 listingType: getListingTypeFromQuery,
184 page: getPageFromString,
185 dataType: getDataTypeFromQuery,
188 const MobileButton = ({
193 textKey: NoOptionI18nKeys;
195 onClick: MouseEventHandler<HTMLButtonElement>;
198 className="btn btn-secondary d-inline-block mb-2 me-3"
201 {i18n.t(textKey)}{" "}
202 <Icon icon={show ? `minus-square` : `plus-square`} classes="icon-inline" />
206 const LinkButton = ({
211 translationKey: NoOptionI18nKeys;
213 <Link className="btn btn-secondary d-block" to={path}>
214 {i18n.t(translationKey)}
218 export class Home extends Component<any, HomeState> {
219 private isoData = setIsoData<HomeData>(this.context);
221 postsRes: { state: "empty" },
222 commentsRes: { state: "empty" },
223 trendingCommunitiesRes: { state: "empty" },
224 siteRes: this.isoData.site_res,
225 showSubscribedMobile: false,
226 showTrendingMobile: false,
227 showSidebarMobile: false,
228 subscribedCollapsed: false,
233 constructor(props: any, context: any) {
234 super(props, context);
236 this.handleSortChange = this.handleSortChange.bind(this);
237 this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
238 this.handleDataTypeChange = this.handleDataTypeChange.bind(this);
239 this.handlePageChange = this.handlePageChange.bind(this);
241 this.handleCreateComment = this.handleCreateComment.bind(this);
242 this.handleEditComment = this.handleEditComment.bind(this);
243 this.handleSaveComment = this.handleSaveComment.bind(this);
244 this.handleBlockPerson = this.handleBlockPerson.bind(this);
245 this.handleDeleteComment = this.handleDeleteComment.bind(this);
246 this.handleRemoveComment = this.handleRemoveComment.bind(this);
247 this.handleCommentVote = this.handleCommentVote.bind(this);
248 this.handleAddModToCommunity = this.handleAddModToCommunity.bind(this);
249 this.handleAddAdmin = this.handleAddAdmin.bind(this);
250 this.handlePurgePerson = this.handlePurgePerson.bind(this);
251 this.handlePurgeComment = this.handlePurgeComment.bind(this);
252 this.handleCommentReport = this.handleCommentReport.bind(this);
253 this.handleDistinguishComment = this.handleDistinguishComment.bind(this);
254 this.handleTransferCommunity = this.handleTransferCommunity.bind(this);
255 this.handleCommentReplyRead = this.handleCommentReplyRead.bind(this);
256 this.handlePersonMentionRead = this.handlePersonMentionRead.bind(this);
257 this.handleBanFromCommunity = this.handleBanFromCommunity.bind(this);
258 this.handleBanPerson = this.handleBanPerson.bind(this);
259 this.handlePostEdit = this.handlePostEdit.bind(this);
260 this.handlePostVote = this.handlePostVote.bind(this);
261 this.handlePostReport = this.handlePostReport.bind(this);
262 this.handleLockPost = this.handleLockPost.bind(this);
263 this.handleDeletePost = this.handleDeletePost.bind(this);
264 this.handleRemovePost = this.handleRemovePost.bind(this);
265 this.handleSavePost = this.handleSavePost.bind(this);
266 this.handlePurgePost = this.handlePurgePost.bind(this);
267 this.handleFeaturePost = this.handleFeaturePost.bind(this);
269 // Only fetch the data if coming from another route
270 if (FirstLoadService.isFirstLoad) {
271 const { trendingCommunitiesRes, commentsRes, postsRes } =
272 this.isoData.routeData;
276 trendingCommunitiesRes,
279 tagline: getRandomFromList(this.state?.siteRes?.taglines ?? [])
286 async componentDidMount() {
288 !this.state.isIsomorphic ||
289 !Object.values(this.isoData.routeData).some(
290 res => res.state === "success" || res.state === "failed"
293 await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
299 componentWillUnmount() {
300 saveScrollPosition(this.context);
303 static async fetchInitialData({
306 query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort },
307 }: InitialFetchRequest<QueryParams<HomeProps>>): Promise<HomeData> {
308 const dataType = getDataTypeFromQuery(urlDataType);
310 // TODO figure out auth default_listingType, default_sort_type
311 const type_ = getListingTypeFromQuery(listingType);
312 const sort = getSortTypeFromQuery(urlSort);
314 const page = urlPage ? Number(urlPage) : 1;
316 let postsRes: RequestState<GetPostsResponse> = { state: "empty" };
317 let commentsRes: RequestState<GetCommentsResponse> = {
321 if (dataType === DataType.Post) {
322 const getPostsForm: GetPosts = {
331 postsRes = await client.getPosts(getPostsForm);
333 const getCommentsForm: GetComments = {
336 sort: postToCommentSortType(sort),
342 commentsRes = await client.getComments(getCommentsForm);
345 const trendingCommunitiesForm: ListCommunities = {
348 limit: trendingFetchLimit,
353 trendingCommunitiesRes: await client.listCommunities(
354 trendingCommunitiesForm
361 get documentTitle(): string {
362 const { name, description } = this.state.siteRes.site_view.site;
364 return description ? `${name} - ${description}` : name;
372 local_site: { site_setup },
378 <div className="home container-lg">
380 title={this.documentTitle}
381 path={this.context.router.route.match.url}
384 <div className="row">
385 <main role="main" className="col-12 col-md-8">
389 dangerouslySetInnerHTML={mdToHtml(tagline)}
392 <div className="d-block d-md-none">{this.mobileView}</div>
395 <aside className="d-none d-md-block col-md-4">
404 get hasFollows(): boolean {
405 const mui = UserService.Instance.myUserInfo;
406 return !!mui && mui.follows.length > 0;
412 site_view: { counts, site },
415 showSubscribedMobile,
421 <div className="row">
422 <div className="col-12">
423 {this.hasFollows && (
426 show={showSubscribedMobile}
427 onClick={linkEvent(this, this.handleShowSubscribedMobile)}
432 show={showTrendingMobile}
433 onClick={linkEvent(this, this.handleShowTrendingMobile)}
437 show={showSidebarMobile}
438 onClick={linkEvent(this, this.handleShowSidebarMobile)}
440 {showSidebarMobile && (
445 showLocal={showLocal(this.isoData)}
449 {showTrendingMobile && (
450 <div className="card border-secondary mb-3">
451 {this.trendingCommunities()}
454 {showSubscribedMobile && (
455 <div className="card border-secondary mb-3">
456 {this.subscribedCommunities(true)}
467 site_view: { counts, site },
473 <div id="sidebarContainer">
474 <section id="sidebarMain" className="card border-secondary mb-3">
475 {this.trendingCommunities()}
481 showLocal={showLocal(this.isoData)}
483 {this.hasFollows && (
484 <div className="accordion">
486 id="sidebarSubscribed"
487 className="card border-secondary mb-3"
489 {this.subscribedCommunities(false)}
497 trendingCommunities() {
498 switch (this.state.trendingCommunitiesRes?.state) {
506 const trending = this.state.trendingCommunitiesRes.data.communities;
509 <header className="card-header d-flex align-items-center">
510 <h5 className="mb-0">
511 <T i18nKey="trending_communities">
513 <Link className="text-body" to="/communities">
519 <div className="card-body">
520 {trending.length > 0 && (
521 <ul className="list-inline">
522 {trending.map(cv => (
523 <li key={cv.community.id} className="list-inline-item">
524 <CommunityLink community={cv.community} />
529 {canCreateCommunity(this.state.siteRes) && (
531 path="/create_community"
532 translationKey="create_a_community"
537 translationKey="explore_communities"
546 subscribedCommunities(isMobile = false) {
547 const { subscribedCollapsed } = this.state;
552 className="card-header d-flex align-items-center"
553 id="sidebarSubscribedHeader"
555 <h5 className="mb-0 d-inline">
556 <T class="d-inline" i18nKey="subscribed_to_communities">
558 <Link className="text-body" to="/communities">
566 className="btn btn-sm text-muted"
567 onClick={linkEvent(this, this.handleCollapseSubscribe)}
569 subscribedCollapsed ? i18n.t("expand") : i18n.t("collapse")
572 subscribedCollapsed ? i18n.t("expand") : i18n.t("collapse")
574 data-bs-toggle="collapse"
575 data-bs-target="#sidebarSubscribedBody"
577 aria-controls="sidebarSubscribedBody"
580 icon={`${subscribedCollapsed ? "plus" : "minus"}-square`}
581 classes="icon-inline"
587 id="sidebarSubscribedBody"
588 className="collapse show"
589 aria-labelledby="sidebarSubscribedHeader"
591 <div className="card-body">
592 <ul className="list-inline mb-0">
593 {UserService.Instance.myUserInfo?.follows.map(cfv => (
595 key={cfv.community.id}
596 className="list-inline-item d-inline-block"
598 <CommunityLink community={cfv.community} />
608 async updateUrl({ dataType, listingType, page, sort }: Partial<HomeProps>) {
610 dataType: urlDataType,
611 listingType: urlListingType,
614 } = getHomeQueryParams();
616 const queryParams: QueryParams<HomeProps> = {
617 dataType: getDataTypeString(dataType ?? urlDataType),
618 listingType: listingType ?? urlListingType,
619 page: (page ?? urlPage).toString(),
620 sort: sort ?? urlSort,
623 this.props.history.push({
625 search: getQueryString(queryParams),
628 await this.fetchData();
632 const { page } = getHomeQueryParams();
635 <div className="main-content-wrapper">
639 <Paginator page={page} onChange={this.handlePageChange} />
646 const { dataType } = getHomeQueryParams();
647 const siteRes = this.state.siteRes;
649 if (dataType === DataType.Post) {
650 switch (this.state.postsRes.state) {
658 const posts = this.state.postsRes.data.posts;
664 enableDownvotes={enableDownvotes(siteRes)}
665 enableNsfw={enableNsfw(siteRes)}
666 allLanguages={siteRes.all_languages}
667 siteLanguages={siteRes.discussion_languages}
668 onBlockPerson={this.handleBlockPerson}
669 onPostEdit={this.handlePostEdit}
670 onPostVote={this.handlePostVote}
671 onPostReport={this.handlePostReport}
672 onLockPost={this.handleLockPost}
673 onDeletePost={this.handleDeletePost}
674 onRemovePost={this.handleRemovePost}
675 onSavePost={this.handleSavePost}
676 onPurgePerson={this.handlePurgePerson}
677 onPurgePost={this.handlePurgePost}
678 onBanPerson={this.handleBanPerson}
679 onBanPersonFromCommunity={this.handleBanFromCommunity}
680 onAddModToCommunity={this.handleAddModToCommunity}
681 onAddAdmin={this.handleAddAdmin}
682 onTransferCommunity={this.handleTransferCommunity}
683 onFeaturePost={this.handleFeaturePost}
689 switch (this.state.commentsRes.state) {
697 const comments = this.state.commentsRes.data.comments;
700 nodes={commentsToFlatNodes(comments)}
701 viewType={CommentViewType.Flat}
702 finished={this.state.finished}
706 enableDownvotes={enableDownvotes(siteRes)}
707 allLanguages={siteRes.all_languages}
708 siteLanguages={siteRes.discussion_languages}
709 onSaveComment={this.handleSaveComment}
710 onBlockPerson={this.handleBlockPerson}
711 onDeleteComment={this.handleDeleteComment}
712 onRemoveComment={this.handleRemoveComment}
713 onCommentVote={this.handleCommentVote}
714 onCommentReport={this.handleCommentReport}
715 onDistinguishComment={this.handleDistinguishComment}
716 onAddModToCommunity={this.handleAddModToCommunity}
717 onAddAdmin={this.handleAddAdmin}
718 onTransferCommunity={this.handleTransferCommunity}
719 onPurgeComment={this.handlePurgeComment}
720 onPurgePerson={this.handlePurgePerson}
721 onCommentReplyRead={this.handleCommentReplyRead}
722 onPersonMentionRead={this.handlePersonMentionRead}
723 onBanPersonFromCommunity={this.handleBanFromCommunity}
724 onBanPerson={this.handleBanPerson}
725 onCreateComment={this.handleCreateComment}
726 onEditComment={this.handleEditComment}
735 const { listingType, dataType, sort } = getHomeQueryParams();
738 <div className="row align-items-center mb-3 g-3">
739 <div className="col-auto">
742 onChange={this.handleDataTypeChange}
745 <div className="col-auto">
748 showLocal={showLocal(this.isoData)}
750 onChange={this.handleListingTypeChange}
753 <div className="col-auto">
754 <SortSelect sort={sort} onChange={this.handleSortChange} />
756 <div className="col-auto ps-0">{getRss(listingType)}</div>
761 async fetchTrendingCommunities() {
762 this.setState({ trendingCommunitiesRes: { state: "loading" } });
764 trendingCommunitiesRes: await HttpService.client.listCommunities({
767 limit: trendingFetchLimit,
774 const auth = myAuth();
775 const { dataType, page, listingType, sort } = getHomeQueryParams();
777 if (dataType === DataType.Post) {
778 this.setState({ postsRes: { state: "loading" } });
780 postsRes: await HttpService.client.getPosts({
790 this.setState({ commentsRes: { state: "loading" } });
792 commentsRes: await HttpService.client.getComments({
795 sort: postToCommentSortType(sort),
803 restoreScrollPosition(this.context);
807 handleShowSubscribedMobile(i: Home) {
808 i.setState({ showSubscribedMobile: !i.state.showSubscribedMobile });
811 handleShowTrendingMobile(i: Home) {
812 i.setState({ showTrendingMobile: !i.state.showTrendingMobile });
815 handleShowSidebarMobile(i: Home) {
816 i.setState({ showSidebarMobile: !i.state.showSidebarMobile });
819 handleCollapseSubscribe(i: Home) {
820 i.setState({ subscribedCollapsed: !i.state.subscribedCollapsed });
823 handlePageChange(page: number) {
824 this.updateUrl({ page });
825 window.scrollTo(0, 0);
828 handleSortChange(val: SortType) {
829 this.updateUrl({ sort: val, page: 1 });
830 window.scrollTo(0, 0);
833 handleListingTypeChange(val: ListingType) {
834 this.updateUrl({ listingType: val, page: 1 });
835 window.scrollTo(0, 0);
838 handleDataTypeChange(val: DataType) {
839 this.updateUrl({ dataType: val, page: 1 });
840 window.scrollTo(0, 0);
843 async handleAddModToCommunity(form: AddModToCommunity) {
844 // TODO not sure what to do here
845 await HttpService.client.addModToCommunity(form);
848 async handlePurgePerson(form: PurgePerson) {
849 const purgePersonRes = await HttpService.client.purgePerson(form);
850 this.purgeItem(purgePersonRes);
853 async handlePurgeComment(form: PurgeComment) {
854 const purgeCommentRes = await HttpService.client.purgeComment(form);
855 this.purgeItem(purgeCommentRes);
858 async handlePurgePost(form: PurgePost) {
859 const purgeRes = await HttpService.client.purgePost(form);
860 this.purgeItem(purgeRes);
863 async handleBlockPerson(form: BlockPerson) {
864 const blockPersonRes = await HttpService.client.blockPerson(form);
865 if (blockPersonRes.state == "success") {
866 updatePersonBlock(blockPersonRes.data);
870 async handleCreateComment(form: CreateComment) {
871 const createCommentRes = await HttpService.client.createComment(form);
872 this.createAndUpdateComments(createCommentRes);
874 return createCommentRes;
877 async handleEditComment(form: EditComment) {
878 const editCommentRes = await HttpService.client.editComment(form);
879 this.findAndUpdateComment(editCommentRes);
881 return editCommentRes;
884 async handleDeleteComment(form: DeleteComment) {
885 const deleteCommentRes = await HttpService.client.deleteComment(form);
886 this.findAndUpdateComment(deleteCommentRes);
889 async handleDeletePost(form: DeletePost) {
890 const deleteRes = await HttpService.client.deletePost(form);
891 this.findAndUpdatePost(deleteRes);
894 async handleRemovePost(form: RemovePost) {
895 const removeRes = await HttpService.client.removePost(form);
896 this.findAndUpdatePost(removeRes);
899 async handleRemoveComment(form: RemoveComment) {
900 const removeCommentRes = await HttpService.client.removeComment(form);
901 this.findAndUpdateComment(removeCommentRes);
904 async handleSaveComment(form: SaveComment) {
905 const saveCommentRes = await HttpService.client.saveComment(form);
906 this.findAndUpdateComment(saveCommentRes);
909 async handleSavePost(form: SavePost) {
910 const saveRes = await HttpService.client.savePost(form);
911 this.findAndUpdatePost(saveRes);
914 async handleFeaturePost(form: FeaturePost) {
915 const featureRes = await HttpService.client.featurePost(form);
916 this.findAndUpdatePost(featureRes);
919 async handleCommentVote(form: CreateCommentLike) {
920 const voteRes = await HttpService.client.likeComment(form);
921 this.findAndUpdateComment(voteRes);
924 async handlePostEdit(form: EditPost) {
925 const res = await HttpService.client.editPost(form);
926 this.findAndUpdatePost(res);
929 async handlePostVote(form: CreatePostLike) {
930 const voteRes = await HttpService.client.likePost(form);
931 this.findAndUpdatePost(voteRes);
934 async handleCommentReport(form: CreateCommentReport) {
935 const reportRes = await HttpService.client.createCommentReport(form);
936 if (reportRes.state == "success") {
937 toast(i18n.t("report_created"));
941 async handlePostReport(form: CreatePostReport) {
942 const reportRes = await HttpService.client.createPostReport(form);
943 if (reportRes.state == "success") {
944 toast(i18n.t("report_created"));
948 async handleLockPost(form: LockPost) {
949 const lockRes = await HttpService.client.lockPost(form);
950 this.findAndUpdatePost(lockRes);
953 async handleDistinguishComment(form: DistinguishComment) {
954 const distinguishRes = await HttpService.client.distinguishComment(form);
955 this.findAndUpdateComment(distinguishRes);
958 async handleAddAdmin(form: AddAdmin) {
959 const addAdminRes = await HttpService.client.addAdmin(form);
961 if (addAdminRes.state == "success") {
962 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
966 async handleTransferCommunity(form: TransferCommunity) {
967 await HttpService.client.transferCommunity(form);
968 toast(i18n.t("transfer_community"));
971 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
972 const readRes = await HttpService.client.markCommentReplyAsRead(form);
973 this.findAndUpdateCommentReply(readRes);
976 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
977 // TODO not sure what to do here. Maybe it is actually optional, because post doesn't need it.
978 await HttpService.client.markPersonMentionAsRead(form);
981 async handleBanFromCommunity(form: BanFromCommunity) {
982 const banRes = await HttpService.client.banFromCommunity(form);
983 this.updateBanFromCommunity(banRes);
986 async handleBanPerson(form: BanPerson) {
987 const banRes = await HttpService.client.banPerson(form);
988 this.updateBan(banRes);
991 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
992 // Maybe not necessary
993 if (banRes.state == "success") {
995 if (s.postsRes.state == "success") {
996 s.postsRes.data.posts
997 .filter(c => c.creator.id == banRes.data.person_view.person.id)
999 c => (c.creator_banned_from_community = banRes.data.banned)
1002 if (s.commentsRes.state == "success") {
1003 s.commentsRes.data.comments
1004 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1006 c => (c.creator_banned_from_community = banRes.data.banned)
1014 updateBan(banRes: RequestState<BanPersonResponse>) {
1015 // Maybe not necessary
1016 if (banRes.state == "success") {
1017 this.setState(s => {
1018 if (s.postsRes.state == "success") {
1019 s.postsRes.data.posts
1020 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1021 .forEach(c => (c.creator.banned = banRes.data.banned));
1023 if (s.commentsRes.state == "success") {
1024 s.commentsRes.data.comments
1025 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1026 .forEach(c => (c.creator.banned = banRes.data.banned));
1033 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1034 if (purgeRes.state == "success") {
1035 toast(i18n.t("purge_success"));
1036 this.context.router.history.push(`/`);
1040 findAndUpdateComment(res: RequestState<CommentResponse>) {
1041 this.setState(s => {
1042 if (s.commentsRes.state == "success" && res.state == "success") {
1043 s.commentsRes.data.comments = editComment(
1044 res.data.comment_view,
1045 s.commentsRes.data.comments
1047 s.finished.set(res.data.comment_view.comment.id, true);
1053 createAndUpdateComments(res: RequestState<CommentResponse>) {
1054 this.setState(s => {
1055 if (s.commentsRes.state == "success" && res.state == "success") {
1056 s.commentsRes.data.comments.unshift(res.data.comment_view);
1058 // Set finished for the parent
1060 getCommentParentId(res.data.comment_view.comment) ?? 0,
1068 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1069 this.setState(s => {
1070 if (s.commentsRes.state == "success" && res.state == "success") {
1071 s.commentsRes.data.comments = editWith(
1072 res.data.comment_reply_view,
1073 s.commentsRes.data.comments
1080 findAndUpdatePost(res: RequestState<PostResponse>) {
1081 this.setState(s => {
1082 if (s.postsRes.state == "success" && res.state == "success") {
1083 s.postsRes.data.posts = editPost(
1085 s.postsRes.data.posts