11 postToCommentSortType,
16 import { isBrowser } from "@utils/browser";
22 } from "@utils/helpers";
23 import { canCreateCommunity } from "@utils/roles";
24 import type { QueryParams } from "@utils/types";
25 import { RouteDataResponse } from "@utils/types";
26 import { NoOptionI18nKeys } from "i18next";
27 import { Component, MouseEventHandler, linkEvent } from "inferno";
28 import { T } from "inferno-i18next-dess";
29 import { Link } from "inferno-router";
34 BanFromCommunityResponse,
58 ListCommunitiesResponse,
61 MarkCommentReplyAsRead,
62 MarkPersonMentionAsRead,
74 } from "lemmy-js-client";
75 import { fetchLimit, relTags, trendingFetchLimit } from "../../config";
80 } from "../../interfaces";
81 import { mdToHtml } from "../../markdown";
82 import { FirstLoadService, I18NextService, UserService } from "../../services";
83 import { HttpService, RequestState } from "../../services/HttpService";
84 import { setupTippy } from "../../tippy";
85 import { toast } from "../../toast";
86 import { CommentNodes } from "../comment/comment-nodes";
87 import { DataTypeSelect } from "../common/data-type-select";
88 import { HtmlTags } from "../common/html-tags";
89 import { Icon, Spinner } from "../common/icon";
90 import { ListingTypeSelect } from "../common/listing-type-select";
91 import { Paginator } from "../common/paginator";
92 import { SortSelect } from "../common/sort-select";
93 import { CommunityLink } from "../community/community-link";
94 import { PostListings } from "../post/post-listings";
95 import { SiteSidebar } from "./site-sidebar";
98 postsRes: RequestState<GetPostsResponse>;
99 commentsRes: RequestState<GetCommentsResponse>;
100 trendingCommunitiesRes: RequestState<ListCommunitiesResponse>;
101 showSubscribedMobile: boolean;
102 showTrendingMobile: boolean;
103 showSidebarMobile: boolean;
104 subscribedCollapsed: boolean;
106 siteRes: GetSiteResponse;
107 finished: Map<CommentId, boolean | undefined>;
108 isIsomorphic: boolean;
111 interface HomeProps {
112 listingType: ListingType;
118 type HomeData = RouteDataResponse<{
119 postsRes: GetPostsResponse;
120 commentsRes: GetCommentsResponse;
121 trendingCommunitiesRes: ListCommunitiesResponse;
124 function getRss(listingType: ListingType) {
125 const { sort } = getHomeQueryParams();
126 const auth = myAuth();
128 let rss: string | undefined = undefined;
130 switch (listingType) {
132 rss = `/feeds/all.xml?sort=${sort}`;
136 rss = `/feeds/local.xml?sort=${sort}`;
140 rss = auth ? `/feeds/front/${auth}.xml?sort=${sort}` : undefined;
148 <a href={rss} rel={relTags} title="RSS">
149 <Icon icon="rss" classes="text-muted small" />
151 <link rel="alternate" type="application/atom+xml" href={rss} />
157 function getDataTypeFromQuery(type?: string): DataType {
158 return type ? DataType[type] : DataType.Post;
161 function getListingTypeFromQuery(type?: string): ListingType {
162 const myListingType =
163 UserService.Instance.myUserInfo?.local_user_view?.local_user
164 ?.default_listing_type;
166 return (type ? (type as ListingType) : myListingType) ?? "Local";
169 function getSortTypeFromQuery(type?: string): SortType {
171 UserService.Instance.myUserInfo?.local_user_view?.local_user
174 return (type ? (type as SortType) : mySortType) ?? "Active";
177 const getHomeQueryParams = () =>
178 getQueryParams<HomeProps>({
179 sort: getSortTypeFromQuery,
180 listingType: getListingTypeFromQuery,
181 page: getPageFromString,
182 dataType: getDataTypeFromQuery,
185 const MobileButton = ({
190 textKey: NoOptionI18nKeys;
192 onClick: MouseEventHandler<HTMLButtonElement>;
195 className="btn btn-secondary d-inline-block mb-2 me-3"
198 {I18NextService.i18n.t(textKey)}{" "}
199 <Icon icon={show ? `minus-square` : `plus-square`} classes="icon-inline" />
203 const LinkButton = ({
208 translationKey: NoOptionI18nKeys;
210 <Link className="btn btn-secondary d-block" to={path}>
211 {I18NextService.i18n.t(translationKey)}
215 export class Home extends Component<any, HomeState> {
216 private isoData = setIsoData<HomeData>(this.context);
218 postsRes: { state: "empty" },
219 commentsRes: { state: "empty" },
220 trendingCommunitiesRes: { state: "empty" },
221 siteRes: this.isoData.site_res,
222 showSubscribedMobile: false,
223 showTrendingMobile: false,
224 showSidebarMobile: false,
225 subscribedCollapsed: false,
230 constructor(props: any, context: any) {
231 super(props, context);
233 this.handleSortChange = this.handleSortChange.bind(this);
234 this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
235 this.handleDataTypeChange = this.handleDataTypeChange.bind(this);
236 this.handlePageChange = this.handlePageChange.bind(this);
238 this.handleCreateComment = this.handleCreateComment.bind(this);
239 this.handleEditComment = this.handleEditComment.bind(this);
240 this.handleSaveComment = this.handleSaveComment.bind(this);
241 this.handleBlockPerson = this.handleBlockPerson.bind(this);
242 this.handleDeleteComment = this.handleDeleteComment.bind(this);
243 this.handleRemoveComment = this.handleRemoveComment.bind(this);
244 this.handleCommentVote = this.handleCommentVote.bind(this);
245 this.handleAddModToCommunity = this.handleAddModToCommunity.bind(this);
246 this.handleAddAdmin = this.handleAddAdmin.bind(this);
247 this.handlePurgePerson = this.handlePurgePerson.bind(this);
248 this.handlePurgeComment = this.handlePurgeComment.bind(this);
249 this.handleCommentReport = this.handleCommentReport.bind(this);
250 this.handleDistinguishComment = this.handleDistinguishComment.bind(this);
251 this.handleTransferCommunity = this.handleTransferCommunity.bind(this);
252 this.handleCommentReplyRead = this.handleCommentReplyRead.bind(this);
253 this.handlePersonMentionRead = this.handlePersonMentionRead.bind(this);
254 this.handleBanFromCommunity = this.handleBanFromCommunity.bind(this);
255 this.handleBanPerson = this.handleBanPerson.bind(this);
256 this.handlePostEdit = this.handlePostEdit.bind(this);
257 this.handlePostVote = this.handlePostVote.bind(this);
258 this.handlePostReport = this.handlePostReport.bind(this);
259 this.handleLockPost = this.handleLockPost.bind(this);
260 this.handleDeletePost = this.handleDeletePost.bind(this);
261 this.handleRemovePost = this.handleRemovePost.bind(this);
262 this.handleSavePost = this.handleSavePost.bind(this);
263 this.handlePurgePost = this.handlePurgePost.bind(this);
264 this.handleFeaturePost = this.handleFeaturePost.bind(this);
266 // Only fetch the data if coming from another route
267 if (!isBrowser() || FirstLoadService.isFirstLoad) {
268 const { trendingCommunitiesRes, commentsRes, postsRes } =
269 this.isoData.routeData;
273 trendingCommunitiesRes,
276 tagline: getRandomFromList(this.state?.siteRes?.taglines ?? [])
283 async componentDidMount() {
285 !this.state.isIsomorphic ||
286 !Object.values(this.isoData.routeData).some(
287 res => res.state === "success" || res.state === "failed"
290 await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
296 static async fetchInitialData({
299 query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort },
300 }: InitialFetchRequest<QueryParams<HomeProps>>): Promise<HomeData> {
301 const dataType = getDataTypeFromQuery(urlDataType);
303 // TODO figure out auth default_listingType, default_sort_type
304 const type_ = getListingTypeFromQuery(listingType);
305 const sort = getSortTypeFromQuery(urlSort);
307 const page = urlPage ? Number(urlPage) : 1;
309 let postsRes: RequestState<GetPostsResponse> = { state: "empty" };
310 let commentsRes: RequestState<GetCommentsResponse> = {
314 if (dataType === DataType.Post) {
315 const getPostsForm: GetPosts = {
324 postsRes = await client.getPosts(getPostsForm);
326 const getCommentsForm: GetComments = {
329 sort: postToCommentSortType(sort),
335 commentsRes = await client.getComments(getCommentsForm);
338 const trendingCommunitiesForm: ListCommunities = {
341 limit: trendingFetchLimit,
346 trendingCommunitiesRes: await client.listCommunities(
347 trendingCommunitiesForm
354 get documentTitle(): string {
355 const { name, description } = this.state.siteRes.site_view.site;
357 return description ? `${name} - ${description}` : name;
365 local_site: { site_setup },
371 <div className="home container-lg">
373 title={this.documentTitle}
374 path={this.context.router.route.match.url}
377 <div className="row">
378 <main role="main" className="col-12 col-md-8">
382 dangerouslySetInnerHTML={mdToHtml(tagline)}
385 <div className="d-block d-md-none">{this.mobileView}</div>
388 <aside className="d-none d-md-block col-md-4">
397 get hasFollows(): boolean {
398 const mui = UserService.Instance.myUserInfo;
399 return !!mui && mui.follows.length > 0;
405 site_view: { counts, site },
408 showSubscribedMobile,
414 <div className="row">
415 <div className="col-12">
416 {this.hasFollows && (
419 show={showSubscribedMobile}
420 onClick={linkEvent(this, this.handleShowSubscribedMobile)}
425 show={showTrendingMobile}
426 onClick={linkEvent(this, this.handleShowTrendingMobile)}
430 show={showSidebarMobile}
431 onClick={linkEvent(this, this.handleShowSidebarMobile)}
433 {showSidebarMobile && (
438 showLocal={showLocal(this.isoData)}
442 {showTrendingMobile && (
443 <div className="card border-secondary mb-3">
444 {this.trendingCommunities()}
447 {showSubscribedMobile && (
448 <div className="card border-secondary mb-3">
449 {this.subscribedCommunities(true)}
460 site_view: { counts, site },
466 <div id="sidebarContainer">
467 <section id="sidebarMain" className="card border-secondary mb-3">
468 {this.trendingCommunities()}
474 showLocal={showLocal(this.isoData)}
476 {this.hasFollows && (
477 <div className="accordion">
479 id="sidebarSubscribed"
480 className="card border-secondary mb-3"
482 {this.subscribedCommunities(false)}
490 trendingCommunities() {
491 switch (this.state.trendingCommunitiesRes?.state) {
499 const trending = this.state.trendingCommunitiesRes.data.communities;
502 <header className="card-header d-flex align-items-center">
503 <h5 className="mb-0">
504 <T i18nKey="trending_communities">
506 <Link className="text-body" to="/communities">
512 <div className="card-body">
513 {trending.length > 0 && (
514 <ul className="list-inline">
515 {trending.map(cv => (
516 <li key={cv.community.id} className="list-inline-item">
517 <CommunityLink community={cv.community} />
522 {canCreateCommunity(this.state.siteRes) && (
524 path="/create_community"
525 translationKey="create_a_community"
530 translationKey="explore_communities"
539 subscribedCommunities(isMobile = false) {
540 const { subscribedCollapsed } = this.state;
545 className="card-header d-flex align-items-center"
546 id="sidebarSubscribedHeader"
548 <h5 className="mb-0 d-inline">
549 <T class="d-inline" i18nKey="subscribed_to_communities">
551 <Link className="text-body" to="/communities">
559 className="btn btn-sm text-muted"
560 onClick={linkEvent(this, this.handleCollapseSubscribe)}
563 ? I18NextService.i18n.t("expand")
564 : I18NextService.i18n.t("collapse")
568 ? I18NextService.i18n.t("expand")
569 : I18NextService.i18n.t("collapse")
572 aria-controls="sidebarSubscribedBody"
575 icon={`${subscribedCollapsed ? "plus" : "minus"}-square`}
576 classes="icon-inline"
581 {!subscribedCollapsed && (
583 id="sidebarSubscribedBody"
584 aria-labelledby="sidebarSubscribedHeader"
586 <div className="card-body">
587 <ul className="list-inline mb-0">
588 {UserService.Instance.myUserInfo?.follows.map(cfv => (
590 key={cfv.community.id}
591 className="list-inline-item d-inline-block"
593 <CommunityLink community={cfv.community} />
604 async updateUrl({ dataType, listingType, page, sort }: Partial<HomeProps>) {
606 dataType: urlDataType,
607 listingType: urlListingType,
610 } = getHomeQueryParams();
612 const queryParams: QueryParams<HomeProps> = {
613 dataType: getDataTypeString(dataType ?? urlDataType),
614 listingType: listingType ?? urlListingType,
615 page: (page ?? urlPage).toString(),
616 sort: sort ?? urlSort,
619 this.props.history.push({
621 search: getQueryString(queryParams),
624 await this.fetchData();
628 const { page } = getHomeQueryParams();
631 <div className="main-content-wrapper">
635 <Paginator page={page} onChange={this.handlePageChange} />
642 const { dataType } = getHomeQueryParams();
643 const siteRes = this.state.siteRes;
645 if (dataType === DataType.Post) {
646 switch (this.state.postsRes?.state) {
654 const posts = this.state.postsRes.data.posts;
660 enableDownvotes={enableDownvotes(siteRes)}
661 enableNsfw={enableNsfw(siteRes)}
662 allLanguages={siteRes.all_languages}
663 siteLanguages={siteRes.discussion_languages}
664 onBlockPerson={this.handleBlockPerson}
665 onPostEdit={this.handlePostEdit}
666 onPostVote={this.handlePostVote}
667 onPostReport={this.handlePostReport}
668 onLockPost={this.handleLockPost}
669 onDeletePost={this.handleDeletePost}
670 onRemovePost={this.handleRemovePost}
671 onSavePost={this.handleSavePost}
672 onPurgePerson={this.handlePurgePerson}
673 onPurgePost={this.handlePurgePost}
674 onBanPerson={this.handleBanPerson}
675 onBanPersonFromCommunity={this.handleBanFromCommunity}
676 onAddModToCommunity={this.handleAddModToCommunity}
677 onAddAdmin={this.handleAddAdmin}
678 onTransferCommunity={this.handleTransferCommunity}
679 onFeaturePost={this.handleFeaturePost}
685 switch (this.state.commentsRes.state) {
693 const comments = this.state.commentsRes.data.comments;
696 nodes={commentsToFlatNodes(comments)}
697 viewType={CommentViewType.Flat}
698 finished={this.state.finished}
702 enableDownvotes={enableDownvotes(siteRes)}
703 allLanguages={siteRes.all_languages}
704 siteLanguages={siteRes.discussion_languages}
705 onSaveComment={this.handleSaveComment}
706 onBlockPerson={this.handleBlockPerson}
707 onDeleteComment={this.handleDeleteComment}
708 onRemoveComment={this.handleRemoveComment}
709 onCommentVote={this.handleCommentVote}
710 onCommentReport={this.handleCommentReport}
711 onDistinguishComment={this.handleDistinguishComment}
712 onAddModToCommunity={this.handleAddModToCommunity}
713 onAddAdmin={this.handleAddAdmin}
714 onTransferCommunity={this.handleTransferCommunity}
715 onPurgeComment={this.handlePurgeComment}
716 onPurgePerson={this.handlePurgePerson}
717 onCommentReplyRead={this.handleCommentReplyRead}
718 onPersonMentionRead={this.handlePersonMentionRead}
719 onBanPersonFromCommunity={this.handleBanFromCommunity}
720 onBanPerson={this.handleBanPerson}
721 onCreateComment={this.handleCreateComment}
722 onEditComment={this.handleEditComment}
731 const { listingType, dataType, sort } = getHomeQueryParams();
734 <div className="row align-items-center mb-3 g-3">
735 <div className="col-auto">
738 onChange={this.handleDataTypeChange}
741 <div className="col-auto">
744 showLocal={showLocal(this.isoData)}
746 onChange={this.handleListingTypeChange}
749 <div className="col-auto">
750 <SortSelect sort={sort} onChange={this.handleSortChange} />
752 <div className="col-auto ps-0">{getRss(listingType)}</div>
757 async fetchTrendingCommunities() {
758 this.setState({ trendingCommunitiesRes: { state: "loading" } });
760 trendingCommunitiesRes: await HttpService.client.listCommunities({
763 limit: trendingFetchLimit,
770 const auth = myAuth();
771 const { dataType, page, listingType, sort } = getHomeQueryParams();
773 if (dataType === DataType.Post) {
774 this.setState({ postsRes: { state: "loading" } });
776 postsRes: await HttpService.client.getPosts({
786 this.setState({ commentsRes: { state: "loading" } });
788 commentsRes: await HttpService.client.getComments({
791 sort: postToCommentSortType(sort),
802 handleShowSubscribedMobile(i: Home) {
803 i.setState({ showSubscribedMobile: !i.state.showSubscribedMobile });
806 handleShowTrendingMobile(i: Home) {
807 i.setState({ showTrendingMobile: !i.state.showTrendingMobile });
810 handleShowSidebarMobile(i: Home) {
811 i.setState({ showSidebarMobile: !i.state.showSidebarMobile });
814 handleCollapseSubscribe(i: Home) {
815 i.setState({ subscribedCollapsed: !i.state.subscribedCollapsed });
818 handlePageChange(page: number) {
819 this.updateUrl({ page });
820 window.scrollTo(0, 0);
823 handleSortChange(val: SortType) {
824 this.updateUrl({ sort: val, page: 1 });
825 window.scrollTo(0, 0);
828 handleListingTypeChange(val: ListingType) {
829 this.updateUrl({ listingType: val, page: 1 });
830 window.scrollTo(0, 0);
833 handleDataTypeChange(val: DataType) {
834 this.updateUrl({ dataType: val, page: 1 });
835 window.scrollTo(0, 0);
838 async handleAddModToCommunity(form: AddModToCommunity) {
839 // TODO not sure what to do here
840 await HttpService.client.addModToCommunity(form);
843 async handlePurgePerson(form: PurgePerson) {
844 const purgePersonRes = await HttpService.client.purgePerson(form);
845 this.purgeItem(purgePersonRes);
848 async handlePurgeComment(form: PurgeComment) {
849 const purgeCommentRes = await HttpService.client.purgeComment(form);
850 this.purgeItem(purgeCommentRes);
853 async handlePurgePost(form: PurgePost) {
854 const purgeRes = await HttpService.client.purgePost(form);
855 this.purgeItem(purgeRes);
858 async handleBlockPerson(form: BlockPerson) {
859 const blockPersonRes = await HttpService.client.blockPerson(form);
860 if (blockPersonRes.state == "success") {
861 updatePersonBlock(blockPersonRes.data);
865 async handleCreateComment(form: CreateComment) {
866 const createCommentRes = await HttpService.client.createComment(form);
867 this.createAndUpdateComments(createCommentRes);
869 return createCommentRes;
872 async handleEditComment(form: EditComment) {
873 const editCommentRes = await HttpService.client.editComment(form);
874 this.findAndUpdateComment(editCommentRes);
876 return editCommentRes;
879 async handleDeleteComment(form: DeleteComment) {
880 const deleteCommentRes = await HttpService.client.deleteComment(form);
881 this.findAndUpdateComment(deleteCommentRes);
884 async handleDeletePost(form: DeletePost) {
885 const deleteRes = await HttpService.client.deletePost(form);
886 this.findAndUpdatePost(deleteRes);
889 async handleRemovePost(form: RemovePost) {
890 const removeRes = await HttpService.client.removePost(form);
891 this.findAndUpdatePost(removeRes);
894 async handleRemoveComment(form: RemoveComment) {
895 const removeCommentRes = await HttpService.client.removeComment(form);
896 this.findAndUpdateComment(removeCommentRes);
899 async handleSaveComment(form: SaveComment) {
900 const saveCommentRes = await HttpService.client.saveComment(form);
901 this.findAndUpdateComment(saveCommentRes);
904 async handleSavePost(form: SavePost) {
905 const saveRes = await HttpService.client.savePost(form);
906 this.findAndUpdatePost(saveRes);
909 async handleFeaturePost(form: FeaturePost) {
910 const featureRes = await HttpService.client.featurePost(form);
911 this.findAndUpdatePost(featureRes);
914 async handleCommentVote(form: CreateCommentLike) {
915 const voteRes = await HttpService.client.likeComment(form);
916 this.findAndUpdateComment(voteRes);
919 async handlePostEdit(form: EditPost) {
920 const res = await HttpService.client.editPost(form);
921 this.findAndUpdatePost(res);
924 async handlePostVote(form: CreatePostLike) {
925 const voteRes = await HttpService.client.likePost(form);
926 this.findAndUpdatePost(voteRes);
929 async handleCommentReport(form: CreateCommentReport) {
930 const reportRes = await HttpService.client.createCommentReport(form);
931 if (reportRes.state == "success") {
932 toast(I18NextService.i18n.t("report_created"));
936 async handlePostReport(form: CreatePostReport) {
937 const reportRes = await HttpService.client.createPostReport(form);
938 if (reportRes.state == "success") {
939 toast(I18NextService.i18n.t("report_created"));
943 async handleLockPost(form: LockPost) {
944 const lockRes = await HttpService.client.lockPost(form);
945 this.findAndUpdatePost(lockRes);
948 async handleDistinguishComment(form: DistinguishComment) {
949 const distinguishRes = await HttpService.client.distinguishComment(form);
950 this.findAndUpdateComment(distinguishRes);
953 async handleAddAdmin(form: AddAdmin) {
954 const addAdminRes = await HttpService.client.addAdmin(form);
956 if (addAdminRes.state == "success") {
957 this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
961 async handleTransferCommunity(form: TransferCommunity) {
962 await HttpService.client.transferCommunity(form);
963 toast(I18NextService.i18n.t("transfer_community"));
966 async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
967 const readRes = await HttpService.client.markCommentReplyAsRead(form);
968 this.findAndUpdateCommentReply(readRes);
971 async handlePersonMentionRead(form: MarkPersonMentionAsRead) {
972 // TODO not sure what to do here. Maybe it is actually optional, because post doesn't need it.
973 await HttpService.client.markPersonMentionAsRead(form);
976 async handleBanFromCommunity(form: BanFromCommunity) {
977 const banRes = await HttpService.client.banFromCommunity(form);
978 this.updateBanFromCommunity(banRes);
981 async handleBanPerson(form: BanPerson) {
982 const banRes = await HttpService.client.banPerson(form);
983 this.updateBan(banRes);
986 updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
987 // Maybe not necessary
988 if (banRes.state == "success") {
990 if (s.postsRes.state == "success") {
991 s.postsRes.data.posts
992 .filter(c => c.creator.id == banRes.data.person_view.person.id)
994 c => (c.creator_banned_from_community = banRes.data.banned)
997 if (s.commentsRes.state == "success") {
998 s.commentsRes.data.comments
999 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1001 c => (c.creator_banned_from_community = banRes.data.banned)
1009 updateBan(banRes: RequestState<BanPersonResponse>) {
1010 // Maybe not necessary
1011 if (banRes.state == "success") {
1012 this.setState(s => {
1013 if (s.postsRes.state == "success") {
1014 s.postsRes.data.posts
1015 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1016 .forEach(c => (c.creator.banned = banRes.data.banned));
1018 if (s.commentsRes.state == "success") {
1019 s.commentsRes.data.comments
1020 .filter(c => c.creator.id == banRes.data.person_view.person.id)
1021 .forEach(c => (c.creator.banned = banRes.data.banned));
1028 purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
1029 if (purgeRes.state == "success") {
1030 toast(I18NextService.i18n.t("purge_success"));
1031 this.context.router.history.push(`/`);
1035 findAndUpdateComment(res: RequestState<CommentResponse>) {
1036 this.setState(s => {
1037 if (s.commentsRes.state == "success" && res.state == "success") {
1038 s.commentsRes.data.comments = editComment(
1039 res.data.comment_view,
1040 s.commentsRes.data.comments
1042 s.finished.set(res.data.comment_view.comment.id, true);
1048 createAndUpdateComments(res: RequestState<CommentResponse>) {
1049 this.setState(s => {
1050 if (s.commentsRes.state == "success" && res.state == "success") {
1051 s.commentsRes.data.comments.unshift(res.data.comment_view);
1053 // Set finished for the parent
1055 getCommentParentId(res.data.comment_view.comment) ?? 0,
1063 findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
1064 this.setState(s => {
1065 if (s.commentsRes.state == "success" && res.state == "success") {
1066 s.commentsRes.data.comments = editWith(
1067 res.data.comment_reply_view,
1068 s.commentsRes.data.comments
1075 findAndUpdatePost(res: RequestState<PostResponse>) {
1076 this.setState(s => {
1077 if (s.postsRes.state == "success" && res.state == "success") {
1078 s.postsRes.data.posts = editPost(
1080 s.postsRes.data.posts