1 import { getQueryParams, getQueryString } from "@utils/helpers";
2 import { canCreateCommunity } from "@utils/roles";
3 import type { QueryParams } from "@utils/types";
4 import { NoOptionI18nKeys } from "i18next";
5 import { Component, MouseEventHandler, linkEvent } from "inferno";
6 import { T } from "inferno-i18next-dess";
7 import { Link } from "inferno-router";
12 BanFromCommunityResponse,
36 ListCommunitiesResponse,
39 MarkCommentReplyAsRead,
40 MarkPersonMentionAsRead,
52 } from "lemmy-js-client";
53 import { i18n } from "../../i18next";
58 } from "../../interfaces";
59 import { UserService } from "../../services";
60 import { FirstLoadService } from "../../services/FirstLoadService";
61 import { HttpService, RequestState } from "../../services/HttpService";
77 postToCommentSortType,
79 restoreScrollPosition,
88 import { CommentNodes } from "../comment/comment-nodes";
89 import { DataTypeSelect } from "../common/data-type-select";
90 import { HtmlTags } from "../common/html-tags";
91 import { Icon, Spinner } from "../common/icon";
92 import { ListingTypeSelect } from "../common/listing-type-select";
93 import { Paginator } from "../common/paginator";
94 import { SortSelect } from "../common/sort-select";
95 import { CommunityLink } from "../community/community-link";
96 import { PostListings } from "../post/post-listings";
97 import { SiteSidebar } from "./site-sidebar";
100 postsRes: RequestState<GetPostsResponse>;
101 commentsRes: RequestState<GetCommentsResponse>;
102 trendingCommunitiesRes: RequestState<ListCommunitiesResponse>;
103 showSubscribedMobile: boolean;
104 showTrendingMobile: boolean;
105 showSidebarMobile: boolean;
106 subscribedCollapsed: boolean;
108 siteRes: GetSiteResponse;
109 finished: Map<CommentId, boolean | undefined>;
110 isIsomorphic: boolean;
113 interface HomeProps {
114 listingType: ListingType;
120 type HomeData = RouteDataResponse<{
121 postsRes: GetPostsResponse;
122 commentsRes: GetCommentsResponse;
123 trendingCommunitiesRes: ListCommunitiesResponse;
126 function getRss(listingType: ListingType) {
127 const { sort } = getHomeQueryParams();
128 const auth = myAuth();
130 let rss: string | undefined = undefined;
132 switch (listingType) {
134 rss = `/feeds/all.xml?sort=${sort}`;
138 rss = `/feeds/local.xml?sort=${sort}`;
142 rss = auth ? `/feeds/front/${auth}.xml?sort=${sort}` : undefined;
150 <a href={rss} rel={relTags} title="RSS">
151 <Icon icon="rss" classes="text-muted small" />
153 <link rel="alternate" type="application/atom+xml" href={rss} />
159 function getDataTypeFromQuery(type?: string): DataType {
160 return type ? DataType[type] : DataType.Post;
163 function getListingTypeFromQuery(type?: string): ListingType {
164 const myListingType =
165 UserService.Instance.myUserInfo?.local_user_view?.local_user
166 ?.default_listing_type;
168 return (type ? (type as ListingType) : myListingType) ?? "Local";
171 function getSortTypeFromQuery(type?: string): SortType {
173 UserService.Instance.myUserInfo?.local_user_view?.local_user
176 return (type ? (type as SortType) : mySortType) ?? "Active";
179 const getHomeQueryParams = () =>
180 getQueryParams<HomeProps>({
181 sort: getSortTypeFromQuery,
182 listingType: getListingTypeFromQuery,
183 page: getPageFromString,
184 dataType: getDataTypeFromQuery,
187 const MobileButton = ({
192 textKey: NoOptionI18nKeys;
194 onClick: MouseEventHandler<HTMLButtonElement>;
197 className="btn btn-secondary d-inline-block mb-2 me-3"
200 {i18n.t(textKey)}{" "}
201 <Icon icon={show ? `minus-square` : `plus-square`} classes="icon-inline" />
205 const LinkButton = ({
210 translationKey: NoOptionI18nKeys;
212 <Link className="btn btn-secondary d-block" to={path}>
213 {i18n.t(translationKey)}
217 export class Home extends Component<any, HomeState> {
218 private isoData = setIsoData<HomeData>(this.context);
220 postsRes: { state: "empty" },
221 commentsRes: { state: "empty" },
222 trendingCommunitiesRes: { state: "empty" },
223 siteRes: this.isoData.site_res,
224 showSubscribedMobile: false,
225 showTrendingMobile: false,
226 showSidebarMobile: false,
227 subscribedCollapsed: false,
232 constructor(props: any, context: any) {
233 super(props, context);
235 this.handleSortChange = this.handleSortChange.bind(this);
236 this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
237 this.handleDataTypeChange = this.handleDataTypeChange.bind(this);
238 this.handlePageChange = this.handlePageChange.bind(this);
240 this.handleCreateComment = this.handleCreateComment.bind(this);
241 this.handleEditComment = this.handleEditComment.bind(this);
242 this.handleSaveComment = this.handleSaveComment.bind(this);
243 this.handleBlockPerson = this.handleBlockPerson.bind(this);
244 this.handleDeleteComment = this.handleDeleteComment.bind(this);
245 this.handleRemoveComment = this.handleRemoveComment.bind(this);
246 this.handleCommentVote = this.handleCommentVote.bind(this);
247 this.handleAddModToCommunity = this.handleAddModToCommunity.bind(this);
248 this.handleAddAdmin = this.handleAddAdmin.bind(this);
249 this.handlePurgePerson = this.handlePurgePerson.bind(this);
250 this.handlePurgeComment = this.handlePurgeComment.bind(this);
251 this.handleCommentReport = this.handleCommentReport.bind(this);
252 this.handleDistinguishComment = this.handleDistinguishComment.bind(this);
253 this.handleTransferCommunity = this.handleTransferCommunity.bind(this);
254 this.handleCommentReplyRead = this.handleCommentReplyRead.bind(this);
255 this.handlePersonMentionRead = this.handlePersonMentionRead.bind(this);
256 this.handleBanFromCommunity = this.handleBanFromCommunity.bind(this);
257 this.handleBanPerson = this.handleBanPerson.bind(this);
258 this.handlePostEdit = this.handlePostEdit.bind(this);
259 this.handlePostVote = this.handlePostVote.bind(this);
260 this.handlePostReport = this.handlePostReport.bind(this);
261 this.handleLockPost = this.handleLockPost.bind(this);
262 this.handleDeletePost = this.handleDeletePost.bind(this);
263 this.handleRemovePost = this.handleRemovePost.bind(this);
264 this.handleSavePost = this.handleSavePost.bind(this);
265 this.handlePurgePost = this.handlePurgePost.bind(this);
266 this.handleFeaturePost = this.handleFeaturePost.bind(this);
268 // Only fetch the data if coming from another route
269 if (FirstLoadService.isFirstLoad) {
270 const { trendingCommunitiesRes, commentsRes, postsRes } =
271 this.isoData.routeData;
275 trendingCommunitiesRes,
278 tagline: getRandomFromList(this.state?.siteRes?.taglines ?? [])
285 async componentDidMount() {
287 !this.state.isIsomorphic ||
288 !Object.values(this.isoData.routeData).some(
289 res => res.state === "success" || res.state === "failed"
292 await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
298 componentWillUnmount() {
299 saveScrollPosition(this.context);
302 static async fetchInitialData({
305 query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort },
306 }: InitialFetchRequest<QueryParams<HomeProps>>): Promise<HomeData> {
307 const dataType = getDataTypeFromQuery(urlDataType);
309 // TODO figure out auth default_listingType, default_sort_type
310 const type_ = getListingTypeFromQuery(listingType);
311 const sort = getSortTypeFromQuery(urlSort);
313 const page = urlPage ? Number(urlPage) : 1;
315 let postsRes: RequestState<GetPostsResponse> = { state: "empty" };
316 let commentsRes: RequestState<GetCommentsResponse> = {
320 if (dataType === DataType.Post) {
321 const getPostsForm: GetPosts = {
330 postsRes = await client.getPosts(getPostsForm);
332 const getCommentsForm: GetComments = {
335 sort: postToCommentSortType(sort),
341 commentsRes = await client.getComments(getCommentsForm);
344 const trendingCommunitiesForm: ListCommunities = {
347 limit: trendingFetchLimit,
352 trendingCommunitiesRes: await client.listCommunities(
353 trendingCommunitiesForm
360 get documentTitle(): string {
361 const { name, description } = this.state.siteRes.site_view.site;
363 return description ? `${name} - ${description}` : name;
371 local_site: { site_setup },
377 <div className="home container-lg">
379 title={this.documentTitle}
380 path={this.context.router.route.match.url}
383 <div className="row">
384 <main role="main" className="col-12 col-md-8">
388 dangerouslySetInnerHTML={mdToHtml(tagline)}
391 <div className="d-block d-md-none">{this.mobileView}</div>
394 <aside className="d-none d-md-block col-md-4">
403 get hasFollows(): boolean {
404 const mui = UserService.Instance.myUserInfo;
405 return !!mui && mui.follows.length > 0;
411 site_view: { counts, site },
414 showSubscribedMobile,
420 <div className="row">
421 <div className="col-12">
422 {this.hasFollows && (
425 show={showSubscribedMobile}
426 onClick={linkEvent(this, this.handleShowSubscribedMobile)}
431 show={showTrendingMobile}
432 onClick={linkEvent(this, this.handleShowTrendingMobile)}
436 show={showSidebarMobile}
437 onClick={linkEvent(this, this.handleShowSidebarMobile)}
439 {showSidebarMobile && (
444 showLocal={showLocal(this.isoData)}
448 {showTrendingMobile && (
449 <div className="card border-secondary mb-3">
450 {this.trendingCommunities()}
453 {showSubscribedMobile && (
454 <div className="card border-secondary mb-3">
455 {this.subscribedCommunities(true)}
466 site_view: { counts, site },
472 <div id="sidebarContainer">
473 <section id="sidebarMain" className="card border-secondary mb-3">
474 {this.trendingCommunities()}
480 showLocal={showLocal(this.isoData)}
482 {this.hasFollows && (
483 <div className="accordion">
485 id="sidebarSubscribed"
486 className="card border-secondary mb-3"
488 {this.subscribedCommunities(false)}
496 trendingCommunities() {
497 switch (this.state.trendingCommunitiesRes?.state) {
505 const trending = this.state.trendingCommunitiesRes.data.communities;
508 <header className="card-header d-flex align-items-center">
509 <h5 className="mb-0">
510 <T i18nKey="trending_communities">
512 <Link className="text-body" to="/communities">
518 <div className="card-body">
519 {trending.length > 0 && (
520 <ul className="list-inline">
521 {trending.map(cv => (
522 <li key={cv.community.id} className="list-inline-item">
523 <CommunityLink community={cv.community} />
528 {canCreateCommunity(this.state.siteRes) && (
530 path="/create_community"
531 translationKey="create_a_community"
536 translationKey="explore_communities"
545 subscribedCommunities(isMobile = false) {
546 const { subscribedCollapsed } = this.state;
551 className="card-header d-flex align-items-center"
552 id="sidebarSubscribedHeader"
554 <h5 className="mb-0 d-inline">
555 <T class="d-inline" i18nKey="subscribed_to_communities">
557 <Link className="text-body" to="/communities">
565 className="btn btn-sm text-muted"
566 onClick={linkEvent(this, this.handleCollapseSubscribe)}
568 subscribedCollapsed ? i18n.t("expand") : i18n.t("collapse")
571 subscribedCollapsed ? i18n.t("expand") : i18n.t("collapse")
573 data-bs-toggle="collapse"
574 data-bs-target="#sidebarSubscribedBody"
576 aria-controls="sidebarSubscribedBody"
579 icon={`${subscribedCollapsed ? "plus" : "minus"}-square`}
580 classes="icon-inline"
586 id="sidebarSubscribedBody"
587 className="collapse show"
588 aria-labelledby="sidebarSubscribedHeader"
590 <div className="card-body">
591 <ul className="list-inline mb-0">
592 {UserService.Instance.myUserInfo?.follows.map(cfv => (
594 key={cfv.community.id}
595 className="list-inline-item d-inline-block"
597 <CommunityLink community={cfv.community} />
607 async updateUrl({ dataType, listingType, page, sort }: Partial<HomeProps>) {
609 dataType: urlDataType,
610 listingType: urlListingType,
613 } = getHomeQueryParams();
615 const queryParams: QueryParams<HomeProps> = {
616 dataType: getDataTypeString(dataType ?? urlDataType),
617 listingType: listingType ?? urlListingType,
618 page: (page ?? urlPage).toString(),
619 sort: sort ?? urlSort,
622 this.props.history.push({
624 search: getQueryString(queryParams),
627 await this.fetchData();
631 const { page } = getHomeQueryParams();
634 <div className="main-content-wrapper">
638 <Paginator page={page} onChange={this.handlePageChange} />
645 const { dataType } = getHomeQueryParams();
646 const siteRes = this.state.siteRes;
648 if (dataType === DataType.Post) {
649 switch (this.state.postsRes.state) {
657 const posts = this.state.postsRes.data.posts;
663 enableDownvotes={enableDownvotes(siteRes)}
664 enableNsfw={enableNsfw(siteRes)}
665 allLanguages={siteRes.all_languages}
666 siteLanguages={siteRes.discussion_languages}
667 onBlockPerson={this.handleBlockPerson}
668 onPostEdit={this.handlePostEdit}
669 onPostVote={this.handlePostVote}
670 onPostReport={this.handlePostReport}
671 onLockPost={this.handleLockPost}
672 onDeletePost={this.handleDeletePost}
673 onRemovePost={this.handleRemovePost}
674 onSavePost={this.handleSavePost}
675 onPurgePerson={this.handlePurgePerson}
676 onPurgePost={this.handlePurgePost}
677 onBanPerson={this.handleBanPerson}
678 onBanPersonFromCommunity={this.handleBanFromCommunity}
679 onAddModToCommunity={this.handleAddModToCommunity}
680 onAddAdmin={this.handleAddAdmin}
681 onTransferCommunity={this.handleTransferCommunity}
682 onFeaturePost={this.handleFeaturePost}
688 switch (this.state.commentsRes.state) {
696 const comments = this.state.commentsRes.data.comments;
699 nodes={commentsToFlatNodes(comments)}
700 viewType={CommentViewType.Flat}
701 finished={this.state.finished}
705 enableDownvotes={enableDownvotes(siteRes)}
706 allLanguages={siteRes.all_languages}
707 siteLanguages={siteRes.discussion_languages}
708 onSaveComment={this.handleSaveComment}
709 onBlockPerson={this.handleBlockPerson}
710 onDeleteComment={this.handleDeleteComment}
711 onRemoveComment={this.handleRemoveComment}
712 onCommentVote={this.handleCommentVote}
713 onCommentReport={this.handleCommentReport}
714 onDistinguishComment={this.handleDistinguishComment}
715 onAddModToCommunity={this.handleAddModToCommunity}
716 onAddAdmin={this.handleAddAdmin}
717 onTransferCommunity={this.handleTransferCommunity}
718 onPurgeComment={this.handlePurgeComment}
719 onPurgePerson={this.handlePurgePerson}
720 onCommentReplyRead={this.handleCommentReplyRead}
721 onPersonMentionRead={this.handlePersonMentionRead}
722 onBanPersonFromCommunity={this.handleBanFromCommunity}
723 onBanPerson={this.handleBanPerson}
724 onCreateComment={this.handleCreateComment}
725 onEditComment={this.handleEditComment}
734 const { listingType, dataType, sort } = getHomeQueryParams();
737 <div className="row align-items-center mb-3 g-3">
738 <div className="col-auto">
741 onChange={this.handleDataTypeChange}
744 <div className="col-auto">
747 showLocal={showLocal(this.isoData)}
749 onChange={this.handleListingTypeChange}
752 <div className="col-auto">
753 <SortSelect sort={sort} onChange={this.handleSortChange} />
755 <div className="col-auto ps-0">{getRss(listingType)}</div>
760 async fetchTrendingCommunities() {
761 this.setState({ trendingCommunitiesRes: { state: "loading" } });
763 trendingCommunitiesRes: await HttpService.client.listCommunities({
766 limit: trendingFetchLimit,
773 const auth = myAuth();
774 const { dataType, page, listingType, sort } = getHomeQueryParams();
776 if (dataType === DataType.Post) {
777 this.setState({ postsRes: { state: "loading" } });
779 postsRes: await HttpService.client.getPosts({
789 this.setState({ commentsRes: { state: "loading" } });
791 commentsRes: await HttpService.client.getComments({
794 sort: postToCommentSortType(sort),
802 restoreScrollPosition(this.context);
806 handleShowSubscribedMobile(i: Home) {
807 i.setState({ showSubscribedMobile: !i.state.showSubscribedMobile });
810 handleShowTrendingMobile(i: Home) {
811 i.setState({ showTrendingMobile: !i.state.showTrendingMobile });
814 handleShowSidebarMobile(i: Home) {
815 i.setState({ showSidebarMobile: !i.state.showSidebarMobile });
818 handleCollapseSubscribe(i: Home) {
819 i.setState({ subscribedCollapsed: !i.state.subscribedCollapsed });
822 handlePageChange(page: number) {
823 this.updateUrl({ page });
824 window.scrollTo(0, 0);
827 handleSortChange(val: SortType) {
828 this.updateUrl({ sort: val, page: 1 });
829 window.scrollTo(0, 0);
832 handleListingTypeChange(val: ListingType) {
833 this.updateUrl({ listingType: val, page: 1 });
834 window.scrollTo(0, 0);
837 handleDataTypeChange(val: DataType) {
838 this.updateUrl({ dataType: val, page: 1 });
839 window.scrollTo(0, 0);
842 async handleAddModToCommunity(form: AddModToCommunity) {
843 // TODO not sure what to do here
844 await HttpService.client.addModToCommunity(form);
847 async handlePurgePerson(form: PurgePerson) {
848 const purgePersonRes = await HttpService.client.purgePerson(form);
849 this.purgeItem(purgePersonRes);
852 async handlePurgeComment(form: PurgeComment) {
853 const purgeCommentRes = await HttpService.client.purgeComment(form);
854 this.purgeItem(purgeCommentRes);
857 async handlePurgePost(form: PurgePost) {
858 const purgeRes = await HttpService.client.purgePost(form);
859 this.purgeItem(purgeRes);
862 async handleBlockPerson(form: BlockPerson) {
863 const blockPersonRes = await HttpService.client.blockPerson(form);
864 if (blockPersonRes.state == "success") {
865 updatePersonBlock(blockPersonRes.data);
869 async handleCreateComment(form: CreateComment) {
870 const createCommentRes = await HttpService.client.createComment(form);
871 this.createAndUpdateComments(createCommentRes);
873 return createCommentRes;
876 async handleEditComment(form: EditComment) {
877 const editCommentRes = await HttpService.client.editComment(form);
878 this.findAndUpdateComment(editCommentRes);
880 return editCommentRes;
883 async handleDeleteComment(form: DeleteComment) {
884 const deleteCommentRes = await HttpService.client.deleteComment(form);
885 this.findAndUpdateComment(deleteCommentRes);
888 async handleDeletePost(form: DeletePost) {
889 const deleteRes = await HttpService.client.deletePost(form);
890 this.findAndUpdatePost(deleteRes);
893 async handleRemovePost(form: RemovePost) {
894 const removeRes = await HttpService.client.removePost(form);
895 this.findAndUpdatePost(removeRes);
898 async handleRemoveComment(form: RemoveComment) {
899 const removeCommentRes = await HttpService.client.removeComment(form);
900 this.findAndUpdateComment(removeCommentRes);
903 async handleSaveComment(form: SaveComment) {
904 const saveCommentRes = await HttpService.client.saveComment(form);
905 this.findAndUpdateComment(saveCommentRes);
908 async handleSavePost(form: SavePost) {
909 const saveRes = await HttpService.client.savePost(form);
910 this.findAndUpdatePost(saveRes);
913 async handleFeaturePost(form: FeaturePost) {
914 const featureRes = await HttpService.client.featurePost(form);
915 this.findAndUpdatePost(featureRes);
918 async handleCommentVote(form: CreateCommentLike) {
919 const voteRes = await HttpService.client.likeComment(form);
920 this.findAndUpdateComment(voteRes);
923 async handlePostEdit(form: EditPost) {
924 const res = await HttpService.client.editPost(form);
925 this.findAndUpdatePost(res);
928 async handlePostVote(form: CreatePostLike) {
929 const voteRes = await HttpService.client.likePost(form);
930 this.findAndUpdatePost(voteRes);
933 async handleCommentReport(form: CreateCommentReport) {
934 const reportRes = await HttpService.client.createCommentReport(form);
935 if (reportRes.state == "success") {
936 toast(i18n.t("report_created"));
940 async handlePostReport(form: CreatePostReport) {
941 const reportRes = await HttpService.client.createPostReport(form);
942 if (reportRes.state == "success") {
943 toast(i18n.t("report_created"));
947 async handleLockPost(form: LockPost) {
948 const lockRes = await HttpService.client.lockPost(form);
949 this.findAndUpdatePost(lockRes);
952 async handleDistinguishComment(form: DistinguishComment) {
953 const distinguishRes = await HttpService.client.distinguishComment(form);
954 this.findAndUpdateComment(distinguishRes);
957 async handleAddAdmin(form: AddAdmin) {
958 const addAdminRes = await HttpService.client.addAdmin(form);
960 if (addAdminRes.state == "success") {
961 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
965 async handleTransferCommunity(form: TransferCommunity) {
966 await HttpService.client.transferCommunity(form);
967 toast(i18n.t("transfer_community"));
970 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
971 const readRes = await HttpService.client.markCommentReplyAsRead(form);
972 this.findAndUpdateCommentReply(readRes);
975 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
976 // TODO not sure what to do here. Maybe it is actually optional, because post doesn't need it.
977 await HttpService.client.markPersonMentionAsRead(form);
980 async handleBanFromCommunity(form: BanFromCommunity) {
981 const banRes = await HttpService.client.banFromCommunity(form);
982 this.updateBanFromCommunity(banRes);
985 async handleBanPerson(form: BanPerson) {
986 const banRes = await HttpService.client.banPerson(form);
987 this.updateBan(banRes);
990 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
991 // Maybe not necessary
992 if (banRes.state == "success") {
994 if (s.postsRes.state == "success") {
995 s.postsRes.data.posts
996 .filter(c => c.creator.id == banRes.data.person_view.person.id)
998 c => (c.creator_banned_from_community = banRes.data.banned)
1001 if (s.commentsRes.state == "success") {
1002 s.commentsRes.data.comments
1003 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1005 c => (c.creator_banned_from_community = banRes.data.banned)
1013 updateBan(banRes: RequestState<BanPersonResponse>) {
1014 // Maybe not necessary
1015 if (banRes.state == "success") {
1016 this.setState(s => {
1017 if (s.postsRes.state == "success") {
1018 s.postsRes.data.posts
1019 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1020 .forEach(c => (c.creator.banned = banRes.data.banned));
1022 if (s.commentsRes.state == "success") {
1023 s.commentsRes.data.comments
1024 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1025 .forEach(c => (c.creator.banned = banRes.data.banned));
1032 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1033 if (purgeRes.state == "success") {
1034 toast(i18n.t("purge_success"));
1035 this.context.router.history.push(`/`);
1039 findAndUpdateComment(res: RequestState<CommentResponse>) {
1040 this.setState(s => {
1041 if (s.commentsRes.state == "success" && res.state == "success") {
1042 s.commentsRes.data.comments = editComment(
1043 res.data.comment_view,
1044 s.commentsRes.data.comments
1046 s.finished.set(res.data.comment_view.comment.id, true);
1052 createAndUpdateComments(res: RequestState<CommentResponse>) {
1053 this.setState(s => {
1054 if (s.commentsRes.state == "success" && res.state == "success") {
1055 s.commentsRes.data.comments.unshift(res.data.comment_view);
1057 // Set finished for the parent
1059 getCommentParentId(res.data.comment_view.comment) ?? 0,
1067 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1068 this.setState(s => {
1069 if (s.commentsRes.state == "success" && res.state == "success") {
1070 s.commentsRes.data.comments = editWith(
1071 res.data.comment_reply_view,
1072 s.commentsRes.data.comments
1079 findAndUpdatePost(res: RequestState<PostResponse>) {
1080 this.setState(s => {
1081 if (s.postsRes.state == "success" && res.state == "success") {
1082 s.postsRes.data.posts = editPost(
1084 s.postsRes.data.posts