FeaturePost,
Language,
LockPost,
- PersonViewSafe,
- PostFeatureType,
+ PersonView,
PostView,
PurgePerson,
PurgePost,
SavePost,
TransferCommunity,
} from "lemmy-js-client";
-import { externalHost } from "../../env";
+import { getExternalHost, getHttpBase } from "../../env";
import { i18n } from "../../i18next";
import { BanType, PostFormParams, PurgeType } from "../../interfaces";
import { UserService, WebSocketService } from "../../services";
amMod,
canAdmin,
canMod,
+ canShare,
futureDaysToUnixTime,
hostname,
isAdmin,
numToSI,
relTags,
setupTippy,
+ share,
showScores,
wsClient,
} from "../../utils";
post_view: PostView;
duplicates?: PostView[];
moderators?: CommunityModeratorView[];
- admins?: PersonViewSafe[];
+ admins?: PersonView[];
allLanguages: Language[];
siteLanguages: number[];
showCommunity?: boolean;
<PersonListing person={post_view.creator} />
{this.creatorIsMod_ && (
- <span className="mx-1 badge badge-light">{i18n.t("mod")}</span>
+ <span className="mx-1 badge badge-muted">{i18n.t("mod")}</span>
)}
{this.creatorIsAdmin_ && (
- <span className="mx-1 badge badge-light">{i18n.t("admin")}</span>
+ <span className="mx-1 badge badge-muted">{i18n.t("admin")}</span>
)}
{post_view.creator.bot_account && (
- <span className="mx-1 badge badge-light">
+ <span className="mx-1 badge badge-muted">
{i18n.t("bot_account").toLowerCase()}
</span>
)}
- {(post_view.creator_banned_from_community ||
- isBanned(post_view.creator)) && (
- <span className="mx-1 badge badge-danger">{i18n.t("banned")}</span>
- )}
- {post_view.creator_blocked && (
- <span className="mx-1 badge badge-danger">{"blocked"}</span>
- )}
{this.props.showCommunity && (
<span>
<span className="mx-1"> {i18n.t("to")} </span>
</span>
)}
</li>
+ {post_view.post.language_id !== 0 && (
+ <span className="mx-1 badge badge-muted">
+ {
+ this.props.allLanguages.find(
+ lang => lang.id === post_view.post.language_id
+ )?.name
+ }
+ </span>
+ )}
<li className="list-inline-item">•</li>
- {url && !(hostname(url) == externalHost) && (
+ {url && !(hostname(url) === getExternalHost()) && (
<>
<li className="list-inline-item">
<a
commentsLine(mobile = false) {
let post = this.props.post_view.post;
+
return (
<div className="d-flex justify-content-start flex-wrap text-muted font-weight-bold mb-1">
{this.commentsButton}
+ {canShare() && (
+ <button
+ className="btn btn-link"
+ onClick={linkEvent(this, this.handleShare)}
+ type="button"
+ >
+ <Icon icon="share" inline />
+ </button>
+ )}
{!post.local && (
<a
className="btn btn-link btn-animate text-muted py-0"
<Link
className="text-muted"
title={i18n.t("number_of_comments", {
- count: post_view.counts.comments,
- formattedCount: post_view.counts.comments,
+ count: Number(post_view.counts.comments),
+ formattedCount: Number(post_view.counts.comments),
})}
to={`/post/${post_view.post.id}?scrollToComments=true`}
>
<Icon icon="message-square" classes="mr-1" inline />
<span className="mr-2">
{i18n.t("number_of_comments", {
- count: post_view.counts.comments,
+ count: Number(post_view.counts.comments),
formattedCount: numToSI(post_view.counts.comments),
})}
</span>
this.setState({ showEdit: false });
}
+ handleShare(i: PostListing) {
+ const { name, body, id } = i.props.post_view.post;
+ share({
+ title: name,
+ text: body?.slice(0, 50),
+ url: `${getHttpBase()}/post/${id}`,
+ });
+ }
+
handleShowReportDialog(i: PostListing) {
i.setState({ showReportDialog: !i.state.showReportDialog });
}
if (auth) {
let form: FeaturePost = {
post_id: i.props.post_view.post.id,
- feature_type: PostFeatureType.Local,
+ feature_type: "Local",
featured: !i.props.post_view.post.featured_local,
auth,
};
if (auth) {
let form: FeaturePost = {
post_id: i.props.post_view.post.id,
- feature_type: PostFeatureType.Community,
+ feature_type: "Community",
featured: !i.props.post_view.post.featured_community,
auth,
};
get pointsTippy(): string {
let points = i18n.t("number_of_points", {
- count: this.state.score,
- formattedCount: this.state.score,
+ count: Number(this.state.score),
+ formattedCount: Number(this.state.score),
});
let upvotes = i18n.t("number_of_upvotes", {
- count: this.state.upvotes,
- formattedCount: this.state.upvotes,
+ count: Number(this.state.upvotes),
+ formattedCount: Number(this.state.upvotes),
});
let downvotes = i18n.t("number_of_downvotes", {
- count: this.state.downvotes,
- formattedCount: this.state.downvotes,
+ count: Number(this.state.downvotes),
+ formattedCount: Number(this.state.downvotes),
});
return `${points} • ${upvotes} • ${downvotes}`;