11 postToCommentSortType,
21 } from "@utils/helpers";
22 import { canCreateCommunity } from "@utils/roles";
23 import type { QueryParams } from "@utils/types";
24 import { RouteDataResponse } from "@utils/types";
25 import { NoOptionI18nKeys } from "i18next";
26 import { Component, MouseEventHandler, linkEvent } from "inferno";
27 import { T } from "inferno-i18next-dess";
28 import { Link } from "inferno-router";
33 BanFromCommunityResponse,
57 ListCommunitiesResponse,
60 MarkCommentReplyAsRead,
61 MarkPersonMentionAsRead,
73 } from "lemmy-js-client";
74 import { fetchLimit, relTags, trendingFetchLimit } from "../../config";
79 } from "../../interfaces";
80 import { mdToHtml } from "../../markdown";
81 import { FirstLoadService, I18NextService, UserService } from "../../services";
82 import { HttpService, RequestState } from "../../services/HttpService";
83 import { setupTippy } from "../../tippy";
84 import { toast } from "../../toast";
85 import { CommentNodes } from "../comment/comment-nodes";
86 import { DataTypeSelect } from "../common/data-type-select";
87 import { HtmlTags } from "../common/html-tags";
88 import { Icon, Spinner } from "../common/icon";
89 import { ListingTypeSelect } from "../common/listing-type-select";
90 import { Paginator } from "../common/paginator";
91 import { SortSelect } from "../common/sort-select";
92 import { CommunityLink } from "../community/community-link";
93 import { PostListings } from "../post/post-listings";
94 import { SiteSidebar } from "./site-sidebar";
97 postsRes: RequestState<GetPostsResponse>;
98 commentsRes: RequestState<GetCommentsResponse>;
99 trendingCommunitiesRes: RequestState<ListCommunitiesResponse>;
100 showSubscribedMobile: boolean;
101 showTrendingMobile: boolean;
102 showSidebarMobile: boolean;
103 subscribedCollapsed: boolean;
105 siteRes: GetSiteResponse;
106 finished: Map<CommentId, boolean | undefined>;
107 isIsomorphic: boolean;
110 interface HomeProps {
111 listingType: ListingType;
117 type HomeData = RouteDataResponse<{
118 postsRes: GetPostsResponse;
119 commentsRes: GetCommentsResponse;
120 trendingCommunitiesRes: ListCommunitiesResponse;
123 function getRss(listingType: ListingType) {
124 const { sort } = getHomeQueryParams();
125 const auth = myAuth();
127 let rss: string | undefined = undefined;
129 switch (listingType) {
131 rss = `/feeds/all.xml?sort=${sort}`;
135 rss = `/feeds/local.xml?sort=${sort}`;
139 rss = auth ? `/feeds/front/${auth}.xml?sort=${sort}` : undefined;
147 <a href={rss} rel={relTags} title="RSS">
148 <Icon icon="rss" classes="text-muted small" />
150 <link rel="alternate" type="application/atom+xml" href={rss} />
156 function getDataTypeFromQuery(type?: string): DataType {
157 return type ? DataType[type] : DataType.Post;
160 function getListingTypeFromQuery(type?: string): ListingType {
161 const myListingType =
162 UserService.Instance.myUserInfo?.local_user_view?.local_user
163 ?.default_listing_type;
165 return (type ? (type as ListingType) : myListingType) ?? "Local";
168 function getSortTypeFromQuery(type?: string): SortType {
170 UserService.Instance.myUserInfo?.local_user_view?.local_user
173 return (type ? (type as SortType) : mySortType) ?? "Active";
176 const getHomeQueryParams = () =>
177 getQueryParams<HomeProps>({
178 sort: getSortTypeFromQuery,
179 listingType: getListingTypeFromQuery,
180 page: getPageFromString,
181 dataType: getDataTypeFromQuery,
184 const MobileButton = ({
189 textKey: NoOptionI18nKeys;
191 onClick: MouseEventHandler<HTMLButtonElement>;
194 className="btn btn-secondary d-inline-block mb-2 me-3"
197 {I18NextService.i18n.t(textKey)}{" "}
198 <Icon icon={show ? `minus-square` : `plus-square`} classes="icon-inline" />
202 const LinkButton = ({
207 translationKey: NoOptionI18nKeys;
209 <Link className="btn btn-secondary d-block" to={path}>
210 {I18NextService.i18n.t(translationKey)}
214 export class Home extends Component<any, HomeState> {
215 private isoData = setIsoData<HomeData>(this.context);
217 postsRes: { state: "empty" },
218 commentsRes: { state: "empty" },
219 trendingCommunitiesRes: { state: "empty" },
220 siteRes: this.isoData.site_res,
221 showSubscribedMobile: false,
222 showTrendingMobile: false,
223 showSidebarMobile: false,
224 subscribedCollapsed: false,
229 constructor(props: any, context: any) {
230 super(props, context);
232 this.handleSortChange = this.handleSortChange.bind(this);
233 this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
234 this.handleDataTypeChange = this.handleDataTypeChange.bind(this);
235 this.handlePageChange = this.handlePageChange.bind(this);
237 this.handleCreateComment = this.handleCreateComment.bind(this);
238 this.handleEditComment = this.handleEditComment.bind(this);
239 this.handleSaveComment = this.handleSaveComment.bind(this);
240 this.handleBlockPerson = this.handleBlockPerson.bind(this);
241 this.handleDeleteComment = this.handleDeleteComment.bind(this);
242 this.handleRemoveComment = this.handleRemoveComment.bind(this);
243 this.handleCommentVote = this.handleCommentVote.bind(this);
244 this.handleAddModToCommunity = this.handleAddModToCommunity.bind(this);
245 this.handleAddAdmin = this.handleAddAdmin.bind(this);
246 this.handlePurgePerson = this.handlePurgePerson.bind(this);
247 this.handlePurgeComment = this.handlePurgeComment.bind(this);
248 this.handleCommentReport = this.handleCommentReport.bind(this);
249 this.handleDistinguishComment = this.handleDistinguishComment.bind(this);
250 this.handleTransferCommunity = this.handleTransferCommunity.bind(this);
251 this.handleCommentReplyRead = this.handleCommentReplyRead.bind(this);
252 this.handlePersonMentionRead = this.handlePersonMentionRead.bind(this);
253 this.handleBanFromCommunity = this.handleBanFromCommunity.bind(this);
254 this.handleBanPerson = this.handleBanPerson.bind(this);
255 this.handlePostEdit = this.handlePostEdit.bind(this);
256 this.handlePostVote = this.handlePostVote.bind(this);
257 this.handlePostReport = this.handlePostReport.bind(this);
258 this.handleLockPost = this.handleLockPost.bind(this);
259 this.handleDeletePost = this.handleDeletePost.bind(this);
260 this.handleRemovePost = this.handleRemovePost.bind(this);
261 this.handleSavePost = this.handleSavePost.bind(this);
262 this.handlePurgePost = this.handlePurgePost.bind(this);
263 this.handleFeaturePost = this.handleFeaturePost.bind(this);
265 // Only fetch the data if coming from another route
266 if (FirstLoadService.isFirstLoad) {
267 const { trendingCommunitiesRes, commentsRes, postsRes } =
268 this.isoData.routeData;
272 trendingCommunitiesRes,
275 tagline: getRandomFromList(this.state?.siteRes?.taglines ?? [])
282 async componentDidMount() {
284 !this.state.isIsomorphic ||
285 !Object.values(this.isoData.routeData).some(
286 res => res.state === "success" || res.state === "failed"
289 await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
295 static async fetchInitialData({
298 query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort },
299 }: InitialFetchRequest<QueryParams<HomeProps>>): Promise<HomeData> {
300 const dataType = getDataTypeFromQuery(urlDataType);
302 // TODO figure out auth default_listingType, default_sort_type
303 const type_ = getListingTypeFromQuery(listingType);
304 const sort = getSortTypeFromQuery(urlSort);
306 const page = urlPage ? Number(urlPage) : 1;
308 let postsRes: RequestState<GetPostsResponse> = { state: "empty" };
309 let commentsRes: RequestState<GetCommentsResponse> = {
313 if (dataType === DataType.Post) {
314 const getPostsForm: GetPosts = {
323 postsRes = await client.getPosts(getPostsForm);
325 const getCommentsForm: GetComments = {
328 sort: postToCommentSortType(sort),
334 commentsRes = await client.getComments(getCommentsForm);
337 const trendingCommunitiesForm: ListCommunities = {
340 limit: trendingFetchLimit,
345 trendingCommunitiesRes: await client.listCommunities(
346 trendingCommunitiesForm
353 get documentTitle(): string {
354 const { name, description } = this.state.siteRes.site_view.site;
356 return description ? `${name} - ${description}` : name;
364 local_site: { site_setup },
370 <div className="home container-lg">
372 title={this.documentTitle}
373 path={this.context.router.route.match.url}
376 <div className="row">
377 <main role="main" className="col-12 col-md-8">
381 dangerouslySetInnerHTML={mdToHtml(tagline)}
384 <div className="d-block d-md-none">{this.mobileView}</div>
387 <aside className="d-none d-md-block col-md-4">
396 get hasFollows(): boolean {
397 const mui = UserService.Instance.myUserInfo;
398 return !!mui && mui.follows.length > 0;
404 site_view: { counts, site },
407 showSubscribedMobile,
413 <div className="row">
414 <div className="col-12">
415 {this.hasFollows && (
418 show={showSubscribedMobile}
419 onClick={linkEvent(this, this.handleShowSubscribedMobile)}
424 show={showTrendingMobile}
425 onClick={linkEvent(this, this.handleShowTrendingMobile)}
429 show={showSidebarMobile}
430 onClick={linkEvent(this, this.handleShowSidebarMobile)}
432 {showSidebarMobile && (
437 showLocal={showLocal(this.isoData)}
441 {showTrendingMobile && (
442 <div className="card border-secondary mb-3">
443 {this.trendingCommunities()}
446 {showSubscribedMobile && (
447 <div className="card border-secondary mb-3">
448 {this.subscribedCommunities(true)}
459 site_view: { counts, site },
465 <div id="sidebarContainer">
466 <section id="sidebarMain" className="card border-secondary mb-3">
467 {this.trendingCommunities()}
473 showLocal={showLocal(this.isoData)}
475 {this.hasFollows && (
476 <div className="accordion">
478 id="sidebarSubscribed"
479 className="card border-secondary mb-3"
481 {this.subscribedCommunities(false)}
489 trendingCommunities() {
490 switch (this.state.trendingCommunitiesRes?.state) {
498 const trending = this.state.trendingCommunitiesRes.data.communities;
501 <header className="card-header d-flex align-items-center">
502 <h5 className="mb-0">
503 <T i18nKey="trending_communities">
505 <Link className="text-body" to="/communities">
511 <div className="card-body">
512 {trending.length > 0 && (
513 <ul className="list-inline">
514 {trending.map(cv => (
515 <li key={cv.community.id} className="list-inline-item">
516 <CommunityLink community={cv.community} />
521 {canCreateCommunity(this.state.siteRes) && (
523 path="/create_community"
524 translationKey="create_a_community"
529 translationKey="explore_communities"
538 subscribedCommunities(isMobile = false) {
539 const { subscribedCollapsed } = this.state;
544 className="card-header d-flex align-items-center"
545 id="sidebarSubscribedHeader"
547 <h5 className="mb-0 d-inline">
548 <T class="d-inline" i18nKey="subscribed_to_communities">
550 <Link className="text-body" to="/communities">
558 className="btn btn-sm text-muted"
559 onClick={linkEvent(this, this.handleCollapseSubscribe)}
562 ? I18NextService.i18n.t("expand")
563 : I18NextService.i18n.t("collapse")
567 ? I18NextService.i18n.t("expand")
568 : I18NextService.i18n.t("collapse")
571 aria-controls="sidebarSubscribedBody"
574 icon={`${subscribedCollapsed ? "plus" : "minus"}-square`}
575 classes="icon-inline"
580 {!subscribedCollapsed && (
582 id="sidebarSubscribedBody"
583 aria-labelledby="sidebarSubscribedHeader"
585 <div className="card-body">
586 <ul className="list-inline mb-0">
587 {UserService.Instance.myUserInfo?.follows.map(cfv => (
589 key={cfv.community.id}
590 className="list-inline-item d-inline-block"
592 <CommunityLink community={cfv.community} />
603 async updateUrl({ dataType, listingType, page, sort }: Partial<HomeProps>) {
605 dataType: urlDataType,
606 listingType: urlListingType,
609 } = getHomeQueryParams();
611 const queryParams: QueryParams<HomeProps> = {
612 dataType: getDataTypeString(dataType ?? urlDataType),
613 listingType: listingType ?? urlListingType,
614 page: (page ?? urlPage).toString(),
615 sort: sort ?? urlSort,
618 this.props.history.push({
620 search: getQueryString(queryParams),
623 await this.fetchData();
627 const { page } = getHomeQueryParams();
630 <div className="main-content-wrapper">
634 <Paginator page={page} onChange={this.handlePageChange} />
641 const { dataType } = getHomeQueryParams();
642 const siteRes = this.state.siteRes;
644 if (dataType === DataType.Post) {
645 switch (this.state.postsRes?.state) {
653 const posts = this.state.postsRes.data.posts;
659 enableDownvotes={enableDownvotes(siteRes)}
660 enableNsfw={enableNsfw(siteRes)}
661 allLanguages={siteRes.all_languages}
662 siteLanguages={siteRes.discussion_languages}
663 onBlockPerson={this.handleBlockPerson}
664 onPostEdit={this.handlePostEdit}
665 onPostVote={this.handlePostVote}
666 onPostReport={this.handlePostReport}
667 onLockPost={this.handleLockPost}
668 onDeletePost={this.handleDeletePost}
669 onRemovePost={this.handleRemovePost}
670 onSavePost={this.handleSavePost}
671 onPurgePerson={this.handlePurgePerson}
672 onPurgePost={this.handlePurgePost}
673 onBanPerson={this.handleBanPerson}
674 onBanPersonFromCommunity={this.handleBanFromCommunity}
675 onAddModToCommunity={this.handleAddModToCommunity}
676 onAddAdmin={this.handleAddAdmin}
677 onTransferCommunity={this.handleTransferCommunity}
678 onFeaturePost={this.handleFeaturePost}
684 switch (this.state.commentsRes.state) {
692 const comments = this.state.commentsRes.data.comments;
695 nodes={commentsToFlatNodes(comments)}
696 viewType={CommentViewType.Flat}
697 finished={this.state.finished}
701 enableDownvotes={enableDownvotes(siteRes)}
702 allLanguages={siteRes.all_languages}
703 siteLanguages={siteRes.discussion_languages}
704 onSaveComment={this.handleSaveComment}
705 onBlockPerson={this.handleBlockPerson}
706 onDeleteComment={this.handleDeleteComment}
707 onRemoveComment={this.handleRemoveComment}
708 onCommentVote={this.handleCommentVote}
709 onCommentReport={this.handleCommentReport}
710 onDistinguishComment={this.handleDistinguishComment}
711 onAddModToCommunity={this.handleAddModToCommunity}
712 onAddAdmin={this.handleAddAdmin}
713 onTransferCommunity={this.handleTransferCommunity}
714 onPurgeComment={this.handlePurgeComment}
715 onPurgePerson={this.handlePurgePerson}
716 onCommentReplyRead={this.handleCommentReplyRead}
717 onPersonMentionRead={this.handlePersonMentionRead}
718 onBanPersonFromCommunity={this.handleBanFromCommunity}
719 onBanPerson={this.handleBanPerson}
720 onCreateComment={this.handleCreateComment}
721 onEditComment={this.handleEditComment}
730 const { listingType, dataType, sort } = getHomeQueryParams();
733 <div className="row align-items-center mb-3 g-3">
734 <div className="col-auto">
737 onChange={this.handleDataTypeChange}
740 <div className="col-auto">
743 showLocal={showLocal(this.isoData)}
745 onChange={this.handleListingTypeChange}
748 <div className="col-auto">
749 <SortSelect sort={sort} onChange={this.handleSortChange} />
751 <div className="col-auto ps-0">{getRss(listingType)}</div>
756 async fetchTrendingCommunities() {
757 this.setState({ trendingCommunitiesRes: { state: "loading" } });
759 trendingCommunitiesRes: await HttpService.client.listCommunities({
762 limit: trendingFetchLimit,
769 const auth = myAuth();
770 const { dataType, page, listingType, sort } = getHomeQueryParams();
772 if (dataType === DataType.Post) {
773 this.setState({ postsRes: { state: "loading" } });
775 postsRes: await HttpService.client.getPosts({
785 this.setState({ commentsRes: { state: "loading" } });
787 commentsRes: await HttpService.client.getComments({
790 sort: postToCommentSortType(sort),
801 handleShowSubscribedMobile(i: Home) {
802 i.setState({ showSubscribedMobile: !i.state.showSubscribedMobile });
805 handleShowTrendingMobile(i: Home) {
806 i.setState({ showTrendingMobile: !i.state.showTrendingMobile });
809 handleShowSidebarMobile(i: Home) {
810 i.setState({ showSidebarMobile: !i.state.showSidebarMobile });
813 handleCollapseSubscribe(i: Home) {
814 i.setState({ subscribedCollapsed: !i.state.subscribedCollapsed });
817 handlePageChange(page: number) {
818 this.updateUrl({ page });
819 window.scrollTo(0, 0);
822 handleSortChange(val: SortType) {
823 this.updateUrl({ sort: val, page: 1 });
824 window.scrollTo(0, 0);
827 handleListingTypeChange(val: ListingType) {
828 this.updateUrl({ listingType: val, page: 1 });
829 window.scrollTo(0, 0);
832 handleDataTypeChange(val: DataType) {
833 this.updateUrl({ dataType: val, page: 1 });
834 window.scrollTo(0, 0);
837 async handleAddModToCommunity(form: AddModToCommunity) {
838 // TODO not sure what to do here
839 await HttpService.client.addModToCommunity(form);
842 async handlePurgePerson(form: PurgePerson) {
843 const purgePersonRes = await HttpService.client.purgePerson(form);
844 this.purgeItem(purgePersonRes);
847 async handlePurgeComment(form: PurgeComment) {
848 const purgeCommentRes = await HttpService.client.purgeComment(form);
849 this.purgeItem(purgeCommentRes);
852 async handlePurgePost(form: PurgePost) {
853 const purgeRes = await HttpService.client.purgePost(form);
854 this.purgeItem(purgeRes);
857 async handleBlockPerson(form: BlockPerson) {
858 const blockPersonRes = await HttpService.client.blockPerson(form);
859 if (blockPersonRes.state == "success") {
860 updatePersonBlock(blockPersonRes.data);
864 async handleCreateComment(form: CreateComment) {
865 const createCommentRes = await HttpService.client.createComment(form);
866 this.createAndUpdateComments(createCommentRes);
868 return createCommentRes;
871 async handleEditComment(form: EditComment) {
872 const editCommentRes = await HttpService.client.editComment(form);
873 this.findAndUpdateComment(editCommentRes);
875 return editCommentRes;
878 async handleDeleteComment(form: DeleteComment) {
879 const deleteCommentRes = await HttpService.client.deleteComment(form);
880 this.findAndUpdateComment(deleteCommentRes);
883 async handleDeletePost(form: DeletePost) {
884 const deleteRes = await HttpService.client.deletePost(form);
885 this.findAndUpdatePost(deleteRes);
888 async handleRemovePost(form: RemovePost) {
889 const removeRes = await HttpService.client.removePost(form);
890 this.findAndUpdatePost(removeRes);
893 async handleRemoveComment(form: RemoveComment) {
894 const removeCommentRes = await HttpService.client.removeComment(form);
895 this.findAndUpdateComment(removeCommentRes);
898 async handleSaveComment(form: SaveComment) {
899 const saveCommentRes = await HttpService.client.saveComment(form);
900 this.findAndUpdateComment(saveCommentRes);
903 async handleSavePost(form: SavePost) {
904 const saveRes = await HttpService.client.savePost(form);
905 this.findAndUpdatePost(saveRes);
908 async handleFeaturePost(form: FeaturePost) {
909 const featureRes = await HttpService.client.featurePost(form);
910 this.findAndUpdatePost(featureRes);
913 async handleCommentVote(form: CreateCommentLike) {
914 const voteRes = await HttpService.client.likeComment(form);
915 this.findAndUpdateComment(voteRes);
918 async handlePostEdit(form: EditPost) {
919 const res = await HttpService.client.editPost(form);
920 this.findAndUpdatePost(res);
923 async handlePostVote(form: CreatePostLike) {
924 const voteRes = await HttpService.client.likePost(form);
925 this.findAndUpdatePost(voteRes);
928 async handleCommentReport(form: CreateCommentReport) {
929 const reportRes = await HttpService.client.createCommentReport(form);
930 if (reportRes.state == "success") {
931 toast(I18NextService.i18n.t("report_created"));
935 async handlePostReport(form: CreatePostReport) {
936 const reportRes = await HttpService.client.createPostReport(form);
937 if (reportRes.state == "success") {
938 toast(I18NextService.i18n.t("report_created"));
942 async handleLockPost(form: LockPost) {
943 const lockRes = await HttpService.client.lockPost(form);
944 this.findAndUpdatePost(lockRes);
947 async handleDistinguishComment(form: DistinguishComment) {
948 const distinguishRes = await HttpService.client.distinguishComment(form);
949 this.findAndUpdateComment(distinguishRes);
952 async handleAddAdmin(form: AddAdmin) {
953 const addAdminRes = await HttpService.client.addAdmin(form);
955 if (addAdminRes.state == "success") {
956 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
960 async handleTransferCommunity(form: TransferCommunity) {
961 await HttpService.client.transferCommunity(form);
962 toast(I18NextService.i18n.t("transfer_community"));
965 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
966 const readRes = await HttpService.client.markCommentReplyAsRead(form);
967 this.findAndUpdateCommentReply(readRes);
970 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
971 // TODO not sure what to do here. Maybe it is actually optional, because post doesn't need it.
972 await HttpService.client.markPersonMentionAsRead(form);
975 async handleBanFromCommunity(form: BanFromCommunity) {
976 const banRes = await HttpService.client.banFromCommunity(form);
977 this.updateBanFromCommunity(banRes);
980 async handleBanPerson(form: BanPerson) {
981 const banRes = await HttpService.client.banPerson(form);
982 this.updateBan(banRes);
985 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
986 // Maybe not necessary
987 if (banRes.state == "success") {
989 if (s.postsRes.state == "success") {
990 s.postsRes.data.posts
991 .filter(c => c.creator.id == banRes.data.person_view.person.id)
993 c => (c.creator_banned_from_community = banRes.data.banned)
996 if (s.commentsRes.state == "success") {
997 s.commentsRes.data.comments
998 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1000 c => (c.creator_banned_from_community = banRes.data.banned)
1008 updateBan(banRes: RequestState<BanPersonResponse>) {
1009 // Maybe not necessary
1010 if (banRes.state == "success") {
1011 this.setState(s => {
1012 if (s.postsRes.state == "success") {
1013 s.postsRes.data.posts
1014 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1015 .forEach(c => (c.creator.banned = banRes.data.banned));
1017 if (s.commentsRes.state == "success") {
1018 s.commentsRes.data.comments
1019 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1020 .forEach(c => (c.creator.banned = banRes.data.banned));
1027 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1028 if (purgeRes.state == "success") {
1029 toast(I18NextService.i18n.t("purge_success"));
1030 this.context.router.history.push(`/`);
1034 findAndUpdateComment(res: RequestState<CommentResponse>) {
1035 this.setState(s => {
1036 if (s.commentsRes.state == "success" && res.state == "success") {
1037 s.commentsRes.data.comments = editComment(
1038 res.data.comment_view,
1039 s.commentsRes.data.comments
1041 s.finished.set(res.data.comment_view.comment.id, true);
1047 createAndUpdateComments(res: RequestState<CommentResponse>) {
1048 this.setState(s => {
1049 if (s.commentsRes.state == "success" && res.state == "success") {
1050 s.commentsRes.data.comments.unshift(res.data.comment_view);
1052 // Set finished for the parent
1054 getCommentParentId(res.data.comment_view.comment) ?? 0,
1062 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1063 this.setState(s => {
1064 if (s.commentsRes.state == "success" && res.state == "success") {
1065 s.commentsRes.data.comments = editWith(
1066 res.data.comment_reply_view,
1067 s.commentsRes.data.comments
1074 findAndUpdatePost(res: RequestState<PostResponse>) {
1075 this.setState(s => {
1076 if (s.postsRes.state == "success" && res.state == "success") {
1077 s.postsRes.data.posts = editPost(
1079 s.postsRes.data.posts