X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fpost%2Fpost-listing.tsx;h=d5ddc2f20e5f285d42d00bf23930120e7ac34b10;hb=a9bcf0567d815afcfbe1775bff3dc1eea66c1c18;hp=3c271659c748482f793366180251148edb412df0;hpb=bf0f80e798b38ee748c0a98ba844d83eac7057b9;p=lemmy-ui.git diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 3c27165..d5ddc2f 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -1,6 +1,12 @@ import { myAuthRequired, newVote, showScores } from "@utils/app"; import { canShare, share } from "@utils/browser"; -import { futureDaysToUnixTime, hostname, numToSI } from "@utils/helpers"; +import { getExternalHost, getHttpBase } from "@utils/env"; +import { + capitalizeFirstLetter, + futureDaysToUnixTime, + hostname, + numToSI, +} from "@utils/helpers"; import { isImage, isVideo } from "@utils/media"; import { amAdmin, @@ -38,11 +44,9 @@ import { TransferCommunity, } from "lemmy-js-client"; import { relTags } from "../../config"; -import { getExternalHost, getHttpBase } from "../../env"; -import { i18n } from "../../i18next"; import { BanType, PostFormParams, PurgeType, VoteType } from "../../interfaces"; import { mdNoImages, mdToHtml, mdToHtmlInline } from "../../markdown"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { setupTippy } from "../../tippy"; import { Icon, PurgeWarning, Spinner } from "../common/icon"; import { MomentTime } from "../common/moment-time"; @@ -235,25 +239,40 @@ export class PostListing extends Component { } get img() { - return this.imageSrc ? ( - <> -
- - - -
-
- - - + if (this.imageSrc) { + return ( + <> +
+ + + +
+
+ + + +
+ + ); + } + + const { post } = this.postView; + const { url } = post; + + if (url && isVideo(url)) { + return ( +
+
- - ) : ( - <> - ); + ); + } + + return <>; } imgThumb(src: string) { @@ -298,9 +317,9 @@ export class PostListing extends Component { {this.imgThumb(this.imageSrc)} @@ -321,17 +340,19 @@ export class PostListing extends Component { } else if (url) { if (!this.props.hideImage && isVideo(url)) { return ( -
- -
+
+
+ +
+
); } else { return ( @@ -347,7 +368,7 @@ export class PostListing extends Component {
@@ -363,20 +384,25 @@ export class PostListing extends Component { {this.creatorIsMod_ && ( - {i18n.t("mod")} + + {I18NextService.i18n.t("mod")} + )} {this.creatorIsAdmin_ && ( - {i18n.t("admin")} + + {I18NextService.i18n.t("admin")} + )} {post_view.creator.bot_account && ( - {i18n.t("bot_account").toLowerCase()} + {I18NextService.i18n.t("bot_account").toLowerCase()} )} {this.props.showCommunity && ( <> {" "} - {i18n.t("to")} + {I18NextService.i18n.t("to")}{" "} + )} {post_view.post.language_id !== 0 && ( @@ -405,8 +431,8 @@ export class PostListing extends Component { this.postView.my_vote == 1 ? "text-info" : "text-muted" }`} onClick={linkEvent(this, this.handleUpvote)} - data-tippy-content={i18n.t("upvote")} - aria-label={i18n.t("upvote")} + data-tippy-content={I18NextService.i18n.t("upvote")} + aria-label={I18NextService.i18n.t("upvote")} aria-pressed={this.postView.my_vote === 1} > {this.state.upvoteLoading ? ( @@ -431,8 +457,8 @@ export class PostListing extends Component { this.postView.my_vote == -1 ? "text-danger" : "text-muted" }`} onClick={linkEvent(this, this.handleDownvote)} - data-tippy-content={i18n.t("downvote")} - aria-label={i18n.t("downvote")} + data-tippy-content={I18NextService.i18n.t("downvote")} + aria-label={I18NextService.i18n.t("downvote")} aria-pressed={this.postView.my_vote === -1} > {this.state.downvoteLoading ? ( @@ -456,7 +482,7 @@ export class PostListing extends Component { : "text-primary" }`} to={`/post/${post.id}`} - title={i18n.t("comments")} + title={I18NextService.i18n.t("comments")} > { (post.thumbnail_url && (
@@ -580,7 +608,9 @@ export class PostListing extends Component { return dupes && dupes.length > 0 ? (
@@ -1303,19 +1351,19 @@ export class PostListing extends Component { {/* TODO hold off on expires until later */} {/*
*/} {/* */} - {/* */} + {/* */} {/*
*/}
@@ -1328,13 +1376,13 @@ export class PostListing extends Component { onSubmit={linkEvent(this, this.handleReportSubmit)} > { )} @@ -1355,13 +1407,13 @@ export class PostListing extends Component { > @@ -1557,10 +1609,9 @@ export class PostListing extends Component { const body = post.body; return body - ? `${i18n.t("cross_posted_from")} ${post.ap_id}\n\n${body.replace( - /^/gm, - "> " - )}` + ? `${I18NextService.i18n.t("cross_posted_from")} ${ + post.ap_id + }\n\n${body.replace(/^/gm, "> ")}` : undefined; } @@ -1822,17 +1873,17 @@ export class PostListing extends Component { } get pointsTippy(): string { - const points = i18n.t("number_of_points", { + const points = I18NextService.i18n.t("number_of_points", { count: Number(this.postView.counts.score), formattedCount: Number(this.postView.counts.score), }); - const upvotes = i18n.t("number_of_upvotes", { + const upvotes = I18NextService.i18n.t("number_of_upvotes", { count: Number(this.postView.counts.upvotes), formattedCount: Number(this.postView.counts.upvotes), }); - const downvotes = i18n.t("number_of_downvotes", { + const downvotes = I18NextService.i18n.t("number_of_downvotes", { count: Number(this.postView.counts.downvotes), formattedCount: Number(this.postView.counts.downvotes), });