X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fpost%2Fpost.tsx;h=eeb713a9cef6538bc483776b3cbb0dbf7313b6b5;hb=53c3cfeade90150b07431386745a24aa699a25ec;hp=8b10c058dcbf420ad619d289bf196fc77d1e8c26;hpb=69a123b6d80766c48a64c15f7d7e1545605bad47;p=lemmy-ui.git diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 8b10c05..eeb713a 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -1,5 +1,30 @@ +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, @@ -51,40 +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 isBrowser from "../../utils/browser/is-browser"; -import debounce from "../../utils/helpers/debounce"; +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 (
-
+
@@ -395,10 +397,10 @@ export class Post extends Component { />
-
{this.sidebar()}
+
+
); } @@ -424,79 +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 ( <> -
+
+ + + +
-
+
+
@@ -585,17 +612,17 @@ export class Post extends Component { {!!this.state.commentId && ( <> {showContextButton && ( )} @@ -829,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")); } } @@ -975,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(`/`); } }