1 import classNames from "classnames";
2 import { NoOptionI18nKeys } from "i18next";
3 import { Component, linkEvent, MouseEventHandler } from "inferno";
4 import { T } from "inferno-i18next-dess";
5 import { Link } from "inferno-router";
10 BanFromCommunityResponse,
34 ListCommunitiesResponse,
37 MarkCommentReplyAsRead,
38 MarkPersonMentionAsRead,
50 } from "lemmy-js-client";
51 import { i18n } from "../../i18next";
56 } from "../../interfaces";
57 import { UserService } from "../../services";
58 import { FirstLoadService } from "../../services/FirstLoadService";
59 import { HttpService, RequestState } from "../../services/HttpService";
77 postToCommentSortType,
80 restoreScrollPosition,
90 import { CommentNodes } from "../comment/comment-nodes";
91 import { DataTypeSelect } from "../common/data-type-select";
92 import { HtmlTags } from "../common/html-tags";
93 import { Icon, Spinner } from "../common/icon";
94 import { ListingTypeSelect } from "../common/listing-type-select";
95 import { Paginator } from "../common/paginator";
96 import { SortSelect } from "../common/sort-select";
97 import { CommunityLink } from "../community/community-link";
98 import { PostListings } from "../post/post-listings";
99 import { SiteSidebar } from "./site-sidebar";
101 interface HomeState {
102 postsRes: RequestState<GetPostsResponse>;
103 commentsRes: RequestState<GetCommentsResponse>;
104 trendingCommunitiesRes: RequestState<ListCommunitiesResponse>;
105 showSubscribedMobile: boolean;
106 showTrendingMobile: boolean;
107 showSidebarMobile: boolean;
108 subscribedCollapsed: boolean;
110 siteRes: GetSiteResponse;
111 finished: Map<CommentId, boolean | undefined>;
112 isIsomorphic: boolean;
115 interface HomeProps {
116 listingType: ListingType;
122 type HomeData = RouteDataResponse<{
123 postsRes: GetPostsResponse;
124 commentsRes: GetCommentsResponse;
125 trendingCommunitiesRes: ListCommunitiesResponse;
128 function getRss(listingType: ListingType) {
129 const { sort } = getHomeQueryParams();
130 const auth = myAuth();
132 let rss: string | undefined = undefined;
134 switch (listingType) {
136 rss = `/feeds/all.xml?sort=${sort}`;
140 rss = `/feeds/local.xml?sort=${sort}`;
144 rss = auth ? `/feeds/front/${auth}.xml?sort=${sort}` : undefined;
152 <a href={rss} rel={relTags} title="RSS">
153 <Icon icon="rss" classes="text-muted small" />
155 <link rel="alternate" type="application/atom+xml" href={rss} />
161 function getDataTypeFromQuery(type?: string): DataType {
162 return type ? DataType[type] : DataType.Post;
165 function getListingTypeFromQuery(type?: string): ListingType {
166 const myListingType =
167 UserService.Instance.myUserInfo?.local_user_view?.local_user
168 ?.default_listing_type;
170 return (type ? (type as ListingType) : myListingType) ?? "Local";
173 function getSortTypeFromQuery(type?: string): SortType {
175 UserService.Instance.myUserInfo?.local_user_view?.local_user
178 return (type ? (type as SortType) : mySortType) ?? "Active";
181 const getHomeQueryParams = () =>
182 getQueryParams<HomeProps>({
183 sort: getSortTypeFromQuery,
184 listingType: getListingTypeFromQuery,
185 page: getPageFromString,
186 dataType: getDataTypeFromQuery,
189 const MobileButton = ({
194 textKey: NoOptionI18nKeys;
196 onClick: MouseEventHandler<HTMLButtonElement>;
199 className="btn btn-secondary d-inline-block mb-2 mr-3"
202 {i18n.t(textKey)}{" "}
203 <Icon icon={show ? `minus-square` : `plus-square`} classes="icon-inline" />
207 const LinkButton = ({
212 translationKey: NoOptionI18nKeys;
214 <Link className="btn btn-secondary btn-block" to={path}>
215 {i18n.t(translationKey)}
219 export class Home extends Component<any, HomeState> {
220 private isoData = setIsoData<HomeData>(this.context);
222 postsRes: { state: "empty" },
223 commentsRes: { state: "empty" },
224 trendingCommunitiesRes: { state: "empty" },
225 siteRes: this.isoData.site_res,
226 showSubscribedMobile: false,
227 showTrendingMobile: false,
228 showSidebarMobile: false,
229 subscribedCollapsed: false,
234 constructor(props: any, context: any) {
235 super(props, context);
237 this.handleSortChange = this.handleSortChange.bind(this);
238 this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
239 this.handleDataTypeChange = this.handleDataTypeChange.bind(this);
240 this.handlePageChange = this.handlePageChange.bind(this);
242 this.handleCreateComment = this.handleCreateComment.bind(this);
243 this.handleEditComment = this.handleEditComment.bind(this);
244 this.handleSaveComment = this.handleSaveComment.bind(this);
245 this.handleBlockPerson = this.handleBlockPerson.bind(this);
246 this.handleDeleteComment = this.handleDeleteComment.bind(this);
247 this.handleRemoveComment = this.handleRemoveComment.bind(this);
248 this.handleCommentVote = this.handleCommentVote.bind(this);
249 this.handleAddModToCommunity = this.handleAddModToCommunity.bind(this);
250 this.handleAddAdmin = this.handleAddAdmin.bind(this);
251 this.handlePurgePerson = this.handlePurgePerson.bind(this);
252 this.handlePurgeComment = this.handlePurgeComment.bind(this);
253 this.handleCommentReport = this.handleCommentReport.bind(this);
254 this.handleDistinguishComment = this.handleDistinguishComment.bind(this);
255 this.handleTransferCommunity = this.handleTransferCommunity.bind(this);
256 this.handleCommentReplyRead = this.handleCommentReplyRead.bind(this);
257 this.handlePersonMentionRead = this.handlePersonMentionRead.bind(this);
258 this.handleBanFromCommunity = this.handleBanFromCommunity.bind(this);
259 this.handleBanPerson = this.handleBanPerson.bind(this);
260 this.handlePostEdit = this.handlePostEdit.bind(this);
261 this.handlePostVote = this.handlePostVote.bind(this);
262 this.handlePostReport = this.handlePostReport.bind(this);
263 this.handleLockPost = this.handleLockPost.bind(this);
264 this.handleDeletePost = this.handleDeletePost.bind(this);
265 this.handleRemovePost = this.handleRemovePost.bind(this);
266 this.handleSavePost = this.handleSavePost.bind(this);
267 this.handlePurgePost = this.handlePurgePost.bind(this);
268 this.handleFeaturePost = this.handleFeaturePost.bind(this);
270 // Only fetch the data if coming from another route
271 if (FirstLoadService.isFirstLoad) {
272 const { trendingCommunitiesRes, commentsRes, postsRes } =
273 this.isoData.routeData;
277 trendingCommunitiesRes,
280 tagline: getRandomFromList(this.state?.siteRes?.taglines ?? [])
287 async componentDidMount() {
289 !this.state.isIsomorphic ||
290 !Object.values(this.isoData.routeData).some(
291 res => res.state === "success" || res.state === "failed"
294 await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
300 componentWillUnmount() {
301 saveScrollPosition(this.context);
304 static async fetchInitialData({
307 query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort },
308 }: InitialFetchRequest<QueryParams<HomeProps>>): Promise<HomeData> {
309 const dataType = getDataTypeFromQuery(urlDataType);
311 // TODO figure out auth default_listingType, default_sort_type
312 const type_ = getListingTypeFromQuery(listingType);
313 const sort = getSortTypeFromQuery(urlSort);
315 const page = urlPage ? Number(urlPage) : 1;
317 let postsRes: RequestState<GetPostsResponse> = { state: "empty" };
318 let commentsRes: RequestState<GetCommentsResponse> = {
322 if (dataType === DataType.Post) {
323 const getPostsForm: GetPosts = {
332 postsRes = await client.getPosts(getPostsForm);
334 const getCommentsForm: GetComments = {
337 sort: postToCommentSortType(sort),
343 commentsRes = await client.getComments(getCommentsForm);
346 const trendingCommunitiesForm: ListCommunities = {
349 limit: trendingFetchLimit,
354 trendingCommunitiesRes: await client.listCommunities(
355 trendingCommunitiesForm
362 get documentTitle(): string {
363 const { name, description } = this.state.siteRes.site_view.site;
365 return description ? `${name} - ${description}` : name;
373 local_site: { site_setup },
379 <div className="container-lg">
381 title={this.documentTitle}
382 path={this.context.router.route.match.url}
385 <div className="row">
386 <main role="main" className="col-12 col-md-8">
390 dangerouslySetInnerHTML={mdToHtml(tagline)}
393 <div className="d-block d-md-none">{this.mobileView}</div>
396 <aside className="d-none d-md-block col-md-4">
405 get hasFollows(): boolean {
406 const mui = UserService.Instance.myUserInfo;
407 return !!mui && mui.follows.length > 0;
413 site_view: { counts, site },
416 showSubscribedMobile,
422 <div className="row">
423 <div className="col-12">
424 {this.hasFollows && (
427 show={showSubscribedMobile}
428 onClick={linkEvent(this, this.handleShowSubscribedMobile)}
433 show={showTrendingMobile}
434 onClick={linkEvent(this, this.handleShowTrendingMobile)}
438 show={showSidebarMobile}
439 onClick={linkEvent(this, this.handleShowSidebarMobile)}
441 {showSidebarMobile && (
446 showLocal={showLocal(this.isoData)}
450 {showTrendingMobile && (
451 <div className="card border-secondary mb-3">
452 {this.trendingCommunities(true)}
455 {showSubscribedMobile && (
456 <div className="card border-secondary mb-3">
457 {this.subscribedCommunities(true)}
468 site_view: { counts, site },
474 <div id="sidebarContainer">
475 <section id="sidebarMain" className="card border-secondary mb-3">
476 {this.trendingCommunities()}
482 showLocal={showLocal(this.isoData)}
484 {this.hasFollows && (
485 <div className="accordion">
487 id="sidebarSubscribed"
488 className="card border-secondary mb-3"
490 {this.subscribedCommunities(false)}
498 trendingCommunities(isMobile = false) {
499 switch (this.state.trendingCommunitiesRes?.state) {
507 const trending = this.state.trendingCommunitiesRes.data.communities;
510 className={classNames({
514 <header className="card-header d-flex align-items-center">
515 <h5 className="mb-0">
516 <T i18nKey="trending_communities">
518 <Link className="text-body" to="/communities">
524 <div className="card-body">
525 <ul className="list-inline">
526 {trending.map(cv => (
527 <li key={cv.community.id} className="list-inline-item">
528 <CommunityLink community={cv.community} />
532 {canCreateCommunity(this.state.siteRes) && (
534 path="/create_community"
535 translationKey="create_a_community"
540 translationKey="explore_communities"
549 subscribedCommunities(isMobile = false) {
550 const { subscribedCollapsed } = this.state;
555 className="card-header d-flex align-items-center"
556 id="sidebarSubscribedHeader"
558 <h5 className="mb-0 d-inline">
559 <T class="d-inline" i18nKey="subscribed_to_communities">
561 <Link className="text-body" to="/communities">
569 className="btn btn-sm text-muted"
570 onClick={linkEvent(this, this.handleCollapseSubscribe)}
572 subscribedCollapsed ? i18n.t("expand") : i18n.t("collapse")
575 subscribedCollapsed ? i18n.t("expand") : i18n.t("collapse")
577 data-bs-toggle="collapse"
578 data-bs-target="#sidebarSubscribedBody"
580 aria-controls="sidebarSubscribedBody"
583 icon={`${subscribedCollapsed ? "plus" : "minus"}-square`}
584 classes="icon-inline"
590 id="sidebarSubscribedBody"
591 className="collapse show"
592 aria-labelledby="sidebarSubscribedHeader"
594 <div className="card-body">
595 <ul className="list-inline mb-0">
596 {UserService.Instance.myUserInfo?.follows.map(cfv => (
598 key={cfv.community.id}
599 className="list-inline-item d-inline-block"
601 <CommunityLink community={cfv.community} />
611 async updateUrl({ dataType, listingType, page, sort }: Partial<HomeProps>) {
613 dataType: urlDataType,
614 listingType: urlListingType,
617 } = getHomeQueryParams();
619 const queryParams: QueryParams<HomeProps> = {
620 dataType: getDataTypeString(dataType ?? urlDataType),
621 listingType: listingType ?? urlListingType,
622 page: (page ?? urlPage).toString(),
623 sort: sort ?? urlSort,
626 this.props.history.push({
628 search: getQueryString(queryParams),
631 await this.fetchData();
635 const { page } = getHomeQueryParams();
638 <div className="main-content-wrapper">
642 <Paginator page={page} onChange={this.handlePageChange} />
649 const { dataType } = getHomeQueryParams();
650 const siteRes = this.state.siteRes;
652 if (dataType === DataType.Post) {
653 switch (this.state.postsRes.state) {
661 const posts = this.state.postsRes.data.posts;
667 enableDownvotes={enableDownvotes(siteRes)}
668 enableNsfw={enableNsfw(siteRes)}
669 allLanguages={siteRes.all_languages}
670 siteLanguages={siteRes.discussion_languages}
671 onBlockPerson={this.handleBlockPerson}
672 onPostEdit={this.handlePostEdit}
673 onPostVote={this.handlePostVote}
674 onPostReport={this.handlePostReport}
675 onLockPost={this.handleLockPost}
676 onDeletePost={this.handleDeletePost}
677 onRemovePost={this.handleRemovePost}
678 onSavePost={this.handleSavePost}
679 onPurgePerson={this.handlePurgePerson}
680 onPurgePost={this.handlePurgePost}
681 onBanPerson={this.handleBanPerson}
682 onBanPersonFromCommunity={this.handleBanFromCommunity}
683 onAddModToCommunity={this.handleAddModToCommunity}
684 onAddAdmin={this.handleAddAdmin}
685 onTransferCommunity={this.handleTransferCommunity}
686 onFeaturePost={this.handleFeaturePost}
692 switch (this.state.commentsRes.state) {
700 const comments = this.state.commentsRes.data.comments;
703 nodes={commentsToFlatNodes(comments)}
704 viewType={CommentViewType.Flat}
705 finished={this.state.finished}
709 enableDownvotes={enableDownvotes(siteRes)}
710 allLanguages={siteRes.all_languages}
711 siteLanguages={siteRes.discussion_languages}
712 onSaveComment={this.handleSaveComment}
713 onBlockPerson={this.handleBlockPerson}
714 onDeleteComment={this.handleDeleteComment}
715 onRemoveComment={this.handleRemoveComment}
716 onCommentVote={this.handleCommentVote}
717 onCommentReport={this.handleCommentReport}
718 onDistinguishComment={this.handleDistinguishComment}
719 onAddModToCommunity={this.handleAddModToCommunity}
720 onAddAdmin={this.handleAddAdmin}
721 onTransferCommunity={this.handleTransferCommunity}
722 onPurgeComment={this.handlePurgeComment}
723 onPurgePerson={this.handlePurgePerson}
724 onCommentReplyRead={this.handleCommentReplyRead}
725 onPersonMentionRead={this.handlePersonMentionRead}
726 onBanPersonFromCommunity={this.handleBanFromCommunity}
727 onBanPerson={this.handleBanPerson}
728 onCreateComment={this.handleCreateComment}
729 onEditComment={this.handleEditComment}
738 const { listingType, dataType, sort } = getHomeQueryParams();
741 <div className="mb-3">
742 <span className="mr-3">
745 onChange={this.handleDataTypeChange}
748 <span className="mr-3">
751 showLocal={showLocal(this.isoData)}
753 onChange={this.handleListingTypeChange}
756 <span className="mr-2">
757 <SortSelect sort={sort} onChange={this.handleSortChange} />
759 {getRss(listingType)}
764 async fetchTrendingCommunities() {
765 this.setState({ trendingCommunitiesRes: { state: "loading" } });
767 trendingCommunitiesRes: await HttpService.client.listCommunities({
770 limit: trendingFetchLimit,
777 const auth = myAuth();
778 const { dataType, page, listingType, sort } = getHomeQueryParams();
780 if (dataType === DataType.Post) {
781 this.setState({ postsRes: { state: "loading" } });
783 postsRes: await HttpService.client.getPosts({
793 this.setState({ commentsRes: { state: "loading" } });
795 commentsRes: await HttpService.client.getComments({
798 sort: postToCommentSortType(sort),
806 restoreScrollPosition(this.context);
810 handleShowSubscribedMobile(i: Home) {
811 i.setState({ showSubscribedMobile: !i.state.showSubscribedMobile });
814 handleShowTrendingMobile(i: Home) {
815 i.setState({ showTrendingMobile: !i.state.showTrendingMobile });
818 handleShowSidebarMobile(i: Home) {
819 i.setState({ showSidebarMobile: !i.state.showSidebarMobile });
822 handleCollapseSubscribe(i: Home) {
823 i.setState({ subscribedCollapsed: !i.state.subscribedCollapsed });
826 handlePageChange(page: number) {
827 this.updateUrl({ page });
828 window.scrollTo(0, 0);
831 handleSortChange(val: SortType) {
832 this.updateUrl({ sort: val, page: 1 });
833 window.scrollTo(0, 0);
836 handleListingTypeChange(val: ListingType) {
837 this.updateUrl({ listingType: val, page: 1 });
838 window.scrollTo(0, 0);
841 handleDataTypeChange(val: DataType) {
842 this.updateUrl({ dataType: val, page: 1 });
843 window.scrollTo(0, 0);
846 async handleAddModToCommunity(form: AddModToCommunity) {
847 // TODO not sure what to do here
848 await HttpService.client.addModToCommunity(form);
851 async handlePurgePerson(form: PurgePerson) {
852 const purgePersonRes = await HttpService.client.purgePerson(form);
853 this.purgeItem(purgePersonRes);
856 async handlePurgeComment(form: PurgeComment) {
857 const purgeCommentRes = await HttpService.client.purgeComment(form);
858 this.purgeItem(purgeCommentRes);
861 async handlePurgePost(form: PurgePost) {
862 const purgeRes = await HttpService.client.purgePost(form);
863 this.purgeItem(purgeRes);
866 async handleBlockPerson(form: BlockPerson) {
867 const blockPersonRes = await HttpService.client.blockPerson(form);
868 if (blockPersonRes.state == "success") {
869 updatePersonBlock(blockPersonRes.data);
873 async handleCreateComment(form: CreateComment) {
874 const createCommentRes = await HttpService.client.createComment(form);
875 this.createAndUpdateComments(createCommentRes);
877 return createCommentRes;
880 async handleEditComment(form: EditComment) {
881 const editCommentRes = await HttpService.client.editComment(form);
882 this.findAndUpdateComment(editCommentRes);
884 return editCommentRes;
887 async handleDeleteComment(form: DeleteComment) {
888 const deleteCommentRes = await HttpService.client.deleteComment(form);
889 this.findAndUpdateComment(deleteCommentRes);
892 async handleDeletePost(form: DeletePost) {
893 const deleteRes = await HttpService.client.deletePost(form);
894 this.findAndUpdatePost(deleteRes);
897 async handleRemovePost(form: RemovePost) {
898 const removeRes = await HttpService.client.removePost(form);
899 this.findAndUpdatePost(removeRes);
902 async handleRemoveComment(form: RemoveComment) {
903 const removeCommentRes = await HttpService.client.removeComment(form);
904 this.findAndUpdateComment(removeCommentRes);
907 async handleSaveComment(form: SaveComment) {
908 const saveCommentRes = await HttpService.client.saveComment(form);
909 this.findAndUpdateComment(saveCommentRes);
912 async handleSavePost(form: SavePost) {
913 const saveRes = await HttpService.client.savePost(form);
914 this.findAndUpdatePost(saveRes);
917 async handleFeaturePost(form: FeaturePost) {
918 const featureRes = await HttpService.client.featurePost(form);
919 this.findAndUpdatePost(featureRes);
922 async handleCommentVote(form: CreateCommentLike) {
923 const voteRes = await HttpService.client.likeComment(form);
924 this.findAndUpdateComment(voteRes);
927 async handlePostEdit(form: EditPost) {
928 const res = await HttpService.client.editPost(form);
929 this.findAndUpdatePost(res);
932 async handlePostVote(form: CreatePostLike) {
933 const voteRes = await HttpService.client.likePost(form);
934 this.findAndUpdatePost(voteRes);
937 async handleCommentReport(form: CreateCommentReport) {
938 const reportRes = await HttpService.client.createCommentReport(form);
939 if (reportRes.state == "success") {
940 toast(i18n.t("report_created"));
944 async handlePostReport(form: CreatePostReport) {
945 const reportRes = await HttpService.client.createPostReport(form);
946 if (reportRes.state == "success") {
947 toast(i18n.t("report_created"));
951 async handleLockPost(form: LockPost) {
952 const lockRes = await HttpService.client.lockPost(form);
953 this.findAndUpdatePost(lockRes);
956 async handleDistinguishComment(form: DistinguishComment) {
957 const distinguishRes = await HttpService.client.distinguishComment(form);
958 this.findAndUpdateComment(distinguishRes);
961 async handleAddAdmin(form: AddAdmin) {
962 const addAdminRes = await HttpService.client.addAdmin(form);
964 if (addAdminRes.state == "success") {
965 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
969 async handleTransferCommunity(form: TransferCommunity) {
970 await HttpService.client.transferCommunity(form);
971 toast(i18n.t("transfer_community"));
974 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
975 const readRes = await HttpService.client.markCommentReplyAsRead(form);
976 this.findAndUpdateCommentReply(readRes);
979 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
980 // TODO not sure what to do here. Maybe it is actually optional, because post doesn't need it.
981 await HttpService.client.markPersonMentionAsRead(form);
984 async handleBanFromCommunity(form: BanFromCommunity) {
985 const banRes = await HttpService.client.banFromCommunity(form);
986 this.updateBanFromCommunity(banRes);
989 async handleBanPerson(form: BanPerson) {
990 const banRes = await HttpService.client.banPerson(form);
991 this.updateBan(banRes);
994 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
995 // Maybe not necessary
996 if (banRes.state == "success") {
998 if (s.postsRes.state == "success") {
999 s.postsRes.data.posts
1000 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1002 c => (c.creator_banned_from_community = banRes.data.banned)
1005 if (s.commentsRes.state == "success") {
1006 s.commentsRes.data.comments
1007 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1009 c => (c.creator_banned_from_community = banRes.data.banned)
1017 updateBan(banRes: RequestState<BanPersonResponse>) {
1018 // Maybe not necessary
1019 if (banRes.state == "success") {
1020 this.setState(s => {
1021 if (s.postsRes.state == "success") {
1022 s.postsRes.data.posts
1023 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1024 .forEach(c => (c.creator.banned = banRes.data.banned));
1026 if (s.commentsRes.state == "success") {
1027 s.commentsRes.data.comments
1028 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1029 .forEach(c => (c.creator.banned = banRes.data.banned));
1036 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1037 if (purgeRes.state == "success") {
1038 toast(i18n.t("purge_success"));
1039 this.context.router.history.push(`/`);
1043 findAndUpdateComment(res: RequestState<CommentResponse>) {
1044 this.setState(s => {
1045 if (s.commentsRes.state == "success" && res.state == "success") {
1046 s.commentsRes.data.comments = editComment(
1047 res.data.comment_view,
1048 s.commentsRes.data.comments
1050 s.finished.set(res.data.comment_view.comment.id, true);
1056 createAndUpdateComments(res: RequestState<CommentResponse>) {
1057 this.setState(s => {
1058 if (s.commentsRes.state == "success" && res.state == "success") {
1059 s.commentsRes.data.comments.unshift(res.data.comment_view);
1061 // Set finished for the parent
1063 getCommentParentId(res.data.comment_view.comment) ?? 0,
1071 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1072 this.setState(s => {
1073 if (s.commentsRes.state == "success" && res.state == "success") {
1074 s.commentsRes.data.comments = editWith(
1075 res.data.comment_reply_view,
1076 s.commentsRes.data.comments
1083 findAndUpdatePost(res: RequestState<PostResponse>) {
1084 this.setState(s => {
1085 if (s.postsRes.state == "success" && res.state == "success") {
1086 s.postsRes.data.posts = editPost(
1088 s.postsRes.data.posts