X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fpost%2Fpost.tsx;h=eeb713a9cef6538bc483776b3cbb0dbf7313b6b5;hb=53c3cfeade90150b07431386745a24aa699a25ec;hp=36a3e3a9c15965c7ac3759e38f873a0cc57f224b;hpb=697df71b2d7f36f2a52849e0cc3324233e0f2ef0;p=lemmy-ui.git diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 36a3e3a..eeb713a 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -1,7 +1,30 @@ -import { isBrowser } from "@utils/browser"; -import { debounce } from "@utils/helpers"; +import { + buildCommentsTree, + commentsToFlatNodes, + editComment, + editWith, + enableDownvotes, + enableNsfw, + getCommentIdFromProps, + getCommentParentId, + getDepthFromComment, + getIdFromProps, + myAuth, + setIsoData, + updateCommunityBlock, + updatePersonBlock, +} from "@utils/app"; +import { + isBrowser, + restoreScrollPosition, + saveScrollPosition, +} from "@utils/browser"; +import { debounce, randomStr } from "@utils/helpers"; +import { isImage } from "@utils/media"; +import { RouteDataResponse } from "@utils/types"; import autosize from "autosize"; -import { Component, createRef, linkEvent, RefObject } from "inferno"; +import classNames from "classnames"; +import { Component, RefObject, createRef, linkEvent } from "inferno"; import { AddAdmin, AddModToCommunity, @@ -53,38 +76,16 @@ import { SavePost, TransferCommunity, } from "lemmy-js-client"; -import { i18n } from "../../i18next"; +import { commentTreeMaxDepth } from "../../config"; import { CommentNodeI, CommentViewType, InitialFetchRequest, } from "../../interfaces"; -import { UserService } from "../../services"; -import { FirstLoadService } from "../../services/FirstLoadService"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { - buildCommentsTree, - commentsToFlatNodes, - commentTreeMaxDepth, - editComment, - editWith, - enableDownvotes, - enableNsfw, - getCommentIdFromProps, - getCommentParentId, - getDepthFromComment, - getIdFromProps, - isImage, - myAuth, - restoreScrollPosition, - RouteDataResponse, - saveScrollPosition, - setIsoData, - setupTippy, - toast, - updateCommunityBlock, - updatePersonBlock, -} from "../../utils"; +import { setupTippy } from "../../tippy"; +import { toast } from "../../toast"; import { CommentForm } from "../comment/comment-form"; import { CommentNodes } from "../comment/comment-nodes"; import { HtmlTags } from "../common/html-tags"; @@ -348,10 +349,11 @@ export class Post extends Component { const res = this.state.postRes.data; return (
-
+
@@ -398,7 +400,7 @@ export class Post extends Component { className="btn btn-secondary d-inline-block mb-2 me-3" onClick={linkEvent(this, this.handleShowSidebarMobile)} > - {i18n.t("sidebar")}{" "} + {I18NextService.i18n.t("sidebar")}{" "} { this.commentsTree()} {this.state.commentViewType == CommentViewType.Flat && this.commentsFlat()} -
-
{this.sidebar()}
+ +
); } @@ -424,84 +428,102 @@ export class Post extends Component { } render() { - return
{this.renderPostRes()}
; + return
{this.renderPostRes()}
; } sortRadios() { + const radioId = + this.state.postRes.state === "success" + ? this.state.postRes.data.post_view.post.id + : randomStr(); + return ( <> -
+
+ + + +
-
+
+
@@ -593,14 +615,14 @@ export class Post extends Component { className="ps-0 d-block btn btn-link text-muted" onClick={linkEvent(this, this.handleViewPost)} > - {i18n.t("view_all_comments")} ➔ + {I18NextService.i18n.t("view_all_comments")} ➔ {showContextButton && ( )} @@ -834,14 +856,14 @@ export class Post extends Component { async handleCommentReport(form: CreateCommentReport) { const reportRes = await HttpService.client.createCommentReport(form); if (reportRes.state == "success") { - toast(i18n.t("report_created")); + toast(I18NextService.i18n.t("report_created")); } } async handlePostReport(form: CreatePostReport) { const reportRes = await HttpService.client.createPostReport(form); if (reportRes.state == "success") { - toast(i18n.t("report_created")); + toast(I18NextService.i18n.t("report_created")); } } @@ -980,7 +1002,7 @@ export class Post extends Component { purgeItem(purgeRes: RequestState) { if (purgeRes.state == "success") { - toast(i18n.t("purge_success")); + toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); } }