2022-01-12 00:53:23 +00:00
|
|
|
import classNames from "classnames";
|
2021-02-22 02:39:04 +00:00
|
|
|
import { Component, linkEvent } from "inferno";
|
|
|
|
import { Link } from "inferno-router";
|
2020-09-06 16:15:25 +00:00
|
|
|
import {
|
2021-07-17 20:42:55 +00:00
|
|
|
AddAdmin,
|
|
|
|
AddModToCommunity,
|
|
|
|
BanFromCommunity,
|
|
|
|
BanPerson,
|
2021-08-20 02:56:18 +00:00
|
|
|
BlockPerson,
|
2021-07-17 20:42:55 +00:00
|
|
|
CommunityModeratorView,
|
2020-12-24 01:58:27 +00:00
|
|
|
CreatePostLike,
|
2021-09-28 10:38:59 +00:00
|
|
|
CreatePostReport,
|
2020-12-24 01:58:27 +00:00
|
|
|
DeletePost,
|
2023-06-14 12:20:40 +00:00
|
|
|
EditPost,
|
2022-12-14 15:03:18 +00:00
|
|
|
FeaturePost,
|
2022-09-22 15:14:58 +00:00
|
|
|
Language,
|
2020-12-24 01:58:27 +00:00
|
|
|
LockPost,
|
2023-05-11 18:32:32 +00:00
|
|
|
PersonView,
|
2021-07-17 20:42:55 +00:00
|
|
|
PostView,
|
2022-06-23 19:44:05 +00:00
|
|
|
PurgePerson,
|
|
|
|
PurgePost,
|
2021-07-17 20:42:55 +00:00
|
|
|
RemovePost,
|
|
|
|
SavePost,
|
2020-12-24 01:58:27 +00:00
|
|
|
TransferCommunity,
|
2021-02-22 02:39:04 +00:00
|
|
|
} from "lemmy-js-client";
|
2023-05-21 18:17:56 +00:00
|
|
|
import { getExternalHost, getHttpBase } from "../../env";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { i18n } from "../../i18next";
|
2023-06-14 12:20:40 +00:00
|
|
|
import { BanType, PostFormParams, PurgeType, VoteType } from "../../interfaces";
|
|
|
|
import { UserService } from "../../services";
|
2020-09-06 16:15:25 +00:00
|
|
|
import {
|
2022-12-14 15:03:18 +00:00
|
|
|
amAdmin,
|
2022-06-21 21:42:29 +00:00
|
|
|
amCommunityCreator,
|
2023-02-21 20:53:51 +00:00
|
|
|
amMod,
|
2022-06-21 21:42:29 +00:00
|
|
|
canAdmin,
|
2020-09-06 16:15:25 +00:00
|
|
|
canMod,
|
2023-05-21 18:17:56 +00:00
|
|
|
canShare,
|
2022-01-09 17:53:11 +00:00
|
|
|
futureDaysToUnixTime,
|
2020-09-06 16:15:25 +00:00
|
|
|
hostname,
|
2022-06-21 21:42:29 +00:00
|
|
|
isAdmin,
|
2022-01-09 17:53:11 +00:00
|
|
|
isBanned,
|
2021-07-17 20:42:55 +00:00
|
|
|
isImage,
|
|
|
|
isMod,
|
|
|
|
isVideo,
|
2022-11-19 02:02:38 +00:00
|
|
|
mdNoImages,
|
2021-07-17 20:42:55 +00:00
|
|
|
mdToHtml,
|
2022-11-18 02:01:52 +00:00
|
|
|
mdToHtmlInline,
|
2023-06-14 12:20:40 +00:00
|
|
|
myAuthRequired,
|
|
|
|
newVote,
|
2021-09-18 16:35:49 +00:00
|
|
|
numToSI,
|
2022-02-24 15:31:44 +00:00
|
|
|
relTags,
|
2021-07-17 20:42:55 +00:00
|
|
|
setupTippy,
|
2023-05-21 18:17:56 +00:00
|
|
|
share,
|
2021-04-09 16:23:30 +00:00
|
|
|
showScores,
|
2021-07-17 20:42:55 +00:00
|
|
|
} from "../../utils";
|
2022-06-23 19:44:05 +00:00
|
|
|
import { Icon, PurgeWarning, Spinner } from "../common/icon";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { MomentTime } from "../common/moment-time";
|
|
|
|
import { PictrsImage } from "../common/pictrs-image";
|
|
|
|
import { CommunityLink } from "../community/community-link";
|
|
|
|
import { PersonListing } from "../person/person-listing";
|
2021-08-19 15:24:13 +00:00
|
|
|
import { MetadataCard } from "./metadata-card";
|
2021-07-17 20:42:55 +00:00
|
|
|
import { PostForm } from "./post-form";
|
2020-09-06 16:15:25 +00:00
|
|
|
|
|
|
|
interface PostListingState {
|
|
|
|
showEdit: boolean;
|
|
|
|
showRemoveDialog: boolean;
|
2022-06-23 19:44:05 +00:00
|
|
|
showPurgeDialog: boolean;
|
2023-01-04 16:56:24 +00:00
|
|
|
purgeReason?: string;
|
|
|
|
purgeType?: PurgeType;
|
2022-06-23 19:44:05 +00:00
|
|
|
purgeLoading: boolean;
|
2023-01-04 16:56:24 +00:00
|
|
|
removeReason?: string;
|
2020-09-06 16:15:25 +00:00
|
|
|
showBanDialog: boolean;
|
2023-01-04 16:56:24 +00:00
|
|
|
banReason?: string;
|
|
|
|
banExpireDays?: number;
|
|
|
|
banType?: BanType;
|
|
|
|
removeData?: boolean;
|
2020-09-06 16:15:25 +00:00
|
|
|
showConfirmTransferSite: boolean;
|
|
|
|
showConfirmTransferCommunity: boolean;
|
|
|
|
imageExpanded: boolean;
|
|
|
|
viewSource: boolean;
|
|
|
|
showAdvanced: boolean;
|
2020-09-26 16:18:49 +00:00
|
|
|
showMoreMobile: boolean;
|
2021-03-25 16:44:16 +00:00
|
|
|
showBody: boolean;
|
2021-09-28 10:38:59 +00:00
|
|
|
showReportDialog: boolean;
|
2023-01-04 16:56:24 +00:00
|
|
|
reportReason?: string;
|
2023-06-14 12:20:40 +00:00
|
|
|
upvoteLoading: boolean;
|
|
|
|
downvoteLoading: boolean;
|
|
|
|
reportLoading: boolean;
|
|
|
|
blockLoading: boolean;
|
|
|
|
lockLoading: boolean;
|
|
|
|
deleteLoading: boolean;
|
|
|
|
removeLoading: boolean;
|
|
|
|
saveLoading: boolean;
|
|
|
|
featureCommunityLoading: boolean;
|
|
|
|
featureLocalLoading: boolean;
|
|
|
|
banLoading: boolean;
|
|
|
|
addModLoading: boolean;
|
|
|
|
addAdminLoading: boolean;
|
|
|
|
transferLoading: boolean;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface PostListingProps {
|
2020-12-24 01:58:27 +00:00
|
|
|
post_view: PostView;
|
2023-06-14 12:20:40 +00:00
|
|
|
crossPosts?: PostView[];
|
2023-01-04 16:56:24 +00:00
|
|
|
moderators?: CommunityModeratorView[];
|
2023-05-11 18:32:32 +00:00
|
|
|
admins?: PersonView[];
|
2022-09-22 15:14:58 +00:00
|
|
|
allLanguages: Language[];
|
2022-12-19 15:57:29 +00:00
|
|
|
siteLanguages: number[];
|
2020-09-06 16:15:25 +00:00
|
|
|
showCommunity?: boolean;
|
|
|
|
showBody?: boolean;
|
2022-11-18 02:11:30 +00:00
|
|
|
hideImage?: boolean;
|
2022-06-21 21:42:29 +00:00
|
|
|
enableDownvotes?: boolean;
|
|
|
|
enableNsfw?: boolean;
|
2022-02-02 14:56:43 +00:00
|
|
|
viewOnly?: boolean;
|
2023-06-14 12:20:40 +00:00
|
|
|
onPostEdit(form: EditPost): void;
|
|
|
|
onPostVote(form: CreatePostLike): void;
|
|
|
|
onPostReport(form: CreatePostReport): void;
|
|
|
|
onBlockPerson(form: BlockPerson): void;
|
|
|
|
onLockPost(form: LockPost): void;
|
|
|
|
onDeletePost(form: DeletePost): void;
|
|
|
|
onRemovePost(form: RemovePost): void;
|
|
|
|
onSavePost(form: SavePost): void;
|
|
|
|
onFeaturePost(form: FeaturePost): void;
|
|
|
|
onPurgePerson(form: PurgePerson): void;
|
|
|
|
onPurgePost(form: PurgePost): void;
|
|
|
|
onBanPersonFromCommunity(form: BanFromCommunity): void;
|
|
|
|
onBanPerson(form: BanPerson): void;
|
|
|
|
onAddModToCommunity(form: AddModToCommunity): void;
|
|
|
|
onAddAdmin(form: AddAdmin): void;
|
|
|
|
onTransferCommunity(form: TransferCommunity): void;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class PostListing extends Component<PostListingProps, PostListingState> {
|
2023-01-04 16:56:24 +00:00
|
|
|
state: PostListingState = {
|
2020-09-06 16:15:25 +00:00
|
|
|
showEdit: false,
|
|
|
|
showRemoveDialog: false,
|
2022-06-23 19:44:05 +00:00
|
|
|
showPurgeDialog: false,
|
|
|
|
purgeType: PurgeType.Person,
|
2020-09-06 16:15:25 +00:00
|
|
|
showBanDialog: false,
|
|
|
|
banType: BanType.Community,
|
2022-04-15 21:22:39 +00:00
|
|
|
removeData: false,
|
2020-09-06 16:15:25 +00:00
|
|
|
showConfirmTransferSite: false,
|
|
|
|
showConfirmTransferCommunity: false,
|
|
|
|
imageExpanded: false,
|
|
|
|
viewSource: false,
|
|
|
|
showAdvanced: false,
|
2020-09-26 16:18:49 +00:00
|
|
|
showMoreMobile: false,
|
2021-03-25 16:44:16 +00:00
|
|
|
showBody: false,
|
2021-09-28 10:38:59 +00:00
|
|
|
showReportDialog: false,
|
2023-06-14 12:20:40 +00:00
|
|
|
upvoteLoading: false,
|
|
|
|
downvoteLoading: false,
|
|
|
|
purgeLoading: false,
|
|
|
|
reportLoading: false,
|
|
|
|
blockLoading: false,
|
|
|
|
lockLoading: false,
|
|
|
|
deleteLoading: false,
|
|
|
|
removeLoading: false,
|
|
|
|
saveLoading: false,
|
|
|
|
featureCommunityLoading: false,
|
|
|
|
featureLocalLoading: false,
|
|
|
|
banLoading: false,
|
|
|
|
addModLoading: false,
|
|
|
|
addAdminLoading: false,
|
|
|
|
transferLoading: false,
|
2020-09-06 16:15:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.handleEditPost = this.handleEditPost.bind(this);
|
|
|
|
this.handleEditCancel = this.handleEditCancel.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps: PostListingProps) {
|
2023-06-14 12:20:40 +00:00
|
|
|
if (this.props !== nextProps) {
|
|
|
|
this.setState({
|
|
|
|
upvoteLoading: false,
|
|
|
|
downvoteLoading: false,
|
|
|
|
purgeLoading: false,
|
|
|
|
reportLoading: false,
|
|
|
|
blockLoading: false,
|
|
|
|
lockLoading: false,
|
|
|
|
deleteLoading: false,
|
|
|
|
removeLoading: false,
|
|
|
|
saveLoading: false,
|
|
|
|
featureCommunityLoading: false,
|
|
|
|
featureLocalLoading: false,
|
|
|
|
banLoading: false,
|
|
|
|
addModLoading: false,
|
|
|
|
addAdminLoading: false,
|
|
|
|
transferLoading: false,
|
|
|
|
imageExpanded: false,
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
get postView(): PostView {
|
|
|
|
return this.props.post_view;
|
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
render() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView.post;
|
2023-04-15 14:47:10 +00:00
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="post-listing">
|
2020-09-06 16:15:25 +00:00
|
|
|
{!this.state.showEdit ? (
|
|
|
|
<>
|
|
|
|
{this.listing()}
|
2022-11-18 02:11:30 +00:00
|
|
|
{this.state.imageExpanded && !this.props.hideImage && this.img}
|
2023-06-14 12:20:40 +00:00
|
|
|
{post.url && this.state.showBody && post.embed_title && (
|
2023-01-04 16:56:24 +00:00
|
|
|
<MetadataCard post={post} />
|
|
|
|
)}
|
2022-06-21 21:42:29 +00:00
|
|
|
{this.showBody && this.body()}
|
2020-09-06 16:15:25 +00:00
|
|
|
</>
|
|
|
|
) : (
|
2023-06-14 12:20:40 +00:00
|
|
|
<PostForm
|
|
|
|
post_view={this.postView}
|
|
|
|
crossPosts={this.props.crossPosts}
|
|
|
|
onEdit={this.handleEditPost}
|
|
|
|
onCancel={this.handleEditCancel}
|
|
|
|
enableNsfw={this.props.enableNsfw}
|
|
|
|
enableDownvotes={this.props.enableDownvotes}
|
|
|
|
allLanguages={this.props.allLanguages}
|
|
|
|
siteLanguages={this.props.siteLanguages}
|
|
|
|
/>
|
2020-09-06 16:15:25 +00:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
body() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const body = this.postView.post.body;
|
2023-01-04 16:56:24 +00:00
|
|
|
return body ? (
|
2023-06-16 20:27:41 +00:00
|
|
|
<article id="postContent" className="col-12 card my-2 p-2">
|
2023-01-04 16:56:24 +00:00
|
|
|
{this.state.viewSource ? (
|
|
|
|
<pre>{body}</pre>
|
|
|
|
) : (
|
|
|
|
<div className="md-div" dangerouslySetInnerHTML={mdToHtml(body)} />
|
|
|
|
)}
|
2023-06-16 20:27:41 +00:00
|
|
|
</article>
|
2023-01-04 16:56:24 +00:00
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
);
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-12 00:53:23 +00:00
|
|
|
get img() {
|
2023-06-14 12:20:40 +00:00
|
|
|
return this.imageSrc ? (
|
2023-01-04 16:56:24 +00:00
|
|
|
<>
|
|
|
|
<div className="offset-sm-3 my-2 d-none d-sm-block">
|
2023-06-14 12:20:40 +00:00
|
|
|
<a href={this.imageSrc} className="d-inline-block">
|
|
|
|
<PictrsImage src={this.imageSrc} />
|
2023-01-04 16:56:24 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div className="my-2 d-block d-sm-none">
|
|
|
|
<a
|
|
|
|
className="d-inline-block"
|
|
|
|
onClick={linkEvent(this, this.handleImageExpandClick)}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
<PictrsImage src={this.imageSrc} />
|
2023-01-04 16:56:24 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
);
|
2022-01-12 00:53:23 +00:00
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
imgThumb(src: string) {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post_view = this.postView;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2020-10-14 19:36:37 +00:00
|
|
|
<PictrsImage
|
2020-09-06 16:15:25 +00:00
|
|
|
src={src}
|
2020-10-14 19:36:37 +00:00
|
|
|
thumbnail
|
2021-02-06 20:20:41 +00:00
|
|
|
alt=""
|
2020-12-24 01:58:27 +00:00
|
|
|
nsfw={post_view.post.nsfw || post_view.community.nsfw}
|
2020-09-06 16:15:25 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-01-04 16:56:24 +00:00
|
|
|
get imageSrc(): string | undefined {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView.post;
|
2023-06-05 21:31:12 +00:00
|
|
|
const url = post.url;
|
|
|
|
const thumbnail = post.thumbnail_url;
|
2022-06-21 21:42:29 +00:00
|
|
|
|
2023-01-04 16:56:24 +00:00
|
|
|
if (url && isImage(url)) {
|
|
|
|
if (url.includes("pictrs")) {
|
2022-06-21 21:42:29 +00:00
|
|
|
return url;
|
2023-01-04 16:56:24 +00:00
|
|
|
} else if (thumbnail) {
|
2022-06-21 21:42:29 +00:00
|
|
|
return thumbnail;
|
2020-09-06 16:15:25 +00:00
|
|
|
} else {
|
2022-06-21 21:42:29 +00:00
|
|
|
return url;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
2023-01-04 16:56:24 +00:00
|
|
|
} else if (thumbnail) {
|
2022-06-21 21:42:29 +00:00
|
|
|
return thumbnail;
|
2020-09-09 00:48:17 +00:00
|
|
|
} else {
|
2023-01-04 16:56:24 +00:00
|
|
|
return undefined;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
thumbnail() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView.post;
|
2023-06-05 21:31:12 +00:00
|
|
|
const url = post.url;
|
|
|
|
const thumbnail = post.thumbnail_url;
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2023-01-04 16:56:24 +00:00
|
|
|
if (!this.props.hideImage && url && isImage(url) && this.imageSrc) {
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2021-09-19 20:29:03 +00:00
|
|
|
<a
|
2023-01-04 16:56:24 +00:00
|
|
|
href={this.imageSrc}
|
2022-09-22 15:03:35 +00:00
|
|
|
className="text-body d-inline-block position-relative mb-2"
|
2021-02-22 02:39:04 +00:00
|
|
|
data-tippy-content={i18n.t("expand_here")}
|
2020-09-06 16:15:25 +00:00
|
|
|
onClick={linkEvent(this, this.handleImageExpandClick)}
|
2021-02-22 02:39:04 +00:00
|
|
|
aria-label={i18n.t("expand_here")}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2023-01-04 16:56:24 +00:00
|
|
|
{this.imgThumb(this.imageSrc)}
|
2021-02-11 20:35:27 +00:00
|
|
|
<Icon icon="image" classes="mini-overlay" />
|
2021-09-19 20:29:03 +00:00
|
|
|
</a>
|
2020-09-06 16:15:25 +00:00
|
|
|
);
|
2023-01-04 16:56:24 +00:00
|
|
|
} else if (!this.props.hideImage && url && thumbnail && this.imageSrc) {
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<a
|
2022-09-22 15:03:35 +00:00
|
|
|
className="text-body d-inline-block position-relative mb-2"
|
2023-01-04 16:56:24 +00:00
|
|
|
href={url}
|
2022-02-24 15:31:44 +00:00
|
|
|
rel={relTags}
|
2023-01-04 16:56:24 +00:00
|
|
|
title={url}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2023-01-04 16:56:24 +00:00
|
|
|
{this.imgThumb(this.imageSrc)}
|
2021-02-11 20:35:27 +00:00
|
|
|
<Icon icon="external-link" classes="mini-overlay" />
|
2020-09-06 16:15:25 +00:00
|
|
|
</a>
|
|
|
|
);
|
2023-01-04 16:56:24 +00:00
|
|
|
} else if (url) {
|
|
|
|
if (!this.props.hideImage && isVideo(url)) {
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="embed-responsive embed-responsive-16by9">
|
2020-09-06 16:15:25 +00:00
|
|
|
<video
|
2022-09-22 15:03:35 +00:00
|
|
|
playsInline
|
2020-09-06 16:15:25 +00:00
|
|
|
muted
|
|
|
|
loop
|
|
|
|
controls
|
2022-09-22 15:03:35 +00:00
|
|
|
className="embed-responsive-item"
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2023-01-04 16:56:24 +00:00
|
|
|
<source src={url} type="video/mp4" />
|
2020-09-06 16:15:25 +00:00
|
|
|
</video>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
2023-01-04 16:56:24 +00:00
|
|
|
<a className="text-body" href={url} title={url} rel={relTags}>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="thumbnail rounded bg-light d-flex justify-content-center">
|
2021-02-11 20:35:27 +00:00
|
|
|
<Icon icon="external-link" classes="d-flex align-items-center" />
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<Link
|
|
|
|
className="text-body"
|
|
|
|
to={`/post/${post.id}`}
|
2021-02-22 02:39:04 +00:00
|
|
|
title={i18n.t("comments")}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="thumbnail rounded bg-light d-flex justify-content-center">
|
2021-02-11 20:35:27 +00:00
|
|
|
<Icon icon="message-square" classes="d-flex align-items-center" />
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
createdLine() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post_view = this.postView;
|
2023-06-05 21:31:12 +00:00
|
|
|
const url = post_view.post.url;
|
|
|
|
const body = post_view.post.body;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2022-09-22 15:03:35 +00:00
|
|
|
<ul className="list-inline mb-1 text-muted small">
|
2020-09-06 16:15:25 +00:00
|
|
|
<li className="list-inline-item">
|
2021-03-15 18:09:31 +00:00
|
|
|
<PersonListing person={post_view.creator} />
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2022-06-21 21:42:29 +00:00
|
|
|
{this.creatorIsMod_ && (
|
2023-05-25 08:52:00 +00:00
|
|
|
<span className="mx-1 badge">{i18n.t("mod")}</span>
|
2020-09-06 16:15:25 +00:00
|
|
|
)}
|
2022-06-21 21:42:29 +00:00
|
|
|
{this.creatorIsAdmin_ && (
|
2023-05-25 08:52:00 +00:00
|
|
|
<span className="mx-1 badge">{i18n.t("admin")}</span>
|
2020-09-06 16:15:25 +00:00
|
|
|
)}
|
2021-10-18 01:44:02 +00:00
|
|
|
{post_view.creator.bot_account && (
|
2023-05-25 08:52:00 +00:00
|
|
|
<span className="mx-1 badge">
|
2021-10-18 01:44:02 +00:00
|
|
|
{i18n.t("bot_account").toLowerCase()}
|
|
|
|
</span>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
{this.props.showCommunity && (
|
|
|
|
<span>
|
2022-09-22 15:03:35 +00:00
|
|
|
<span className="mx-1"> {i18n.t("to")} </span>
|
2020-12-24 01:58:27 +00:00
|
|
|
<CommunityLink community={post_view.community} />
|
2020-09-06 16:15:25 +00:00
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</li>
|
2023-05-24 10:22:24 +00:00
|
|
|
{post_view.post.language_id !== 0 && (
|
2023-05-25 08:52:00 +00:00
|
|
|
<span className="mx-1 badge">
|
2023-05-23 20:16:54 +00:00
|
|
|
{
|
|
|
|
this.props.allLanguages.find(
|
|
|
|
lang => lang.id === post_view.post.language_id
|
|
|
|
)?.name
|
|
|
|
}
|
|
|
|
</span>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
<li className="list-inline-item">•</li>
|
2023-05-12 01:07:59 +00:00
|
|
|
{url && !(hostname(url) === getExternalHost()) && (
|
2023-01-04 16:56:24 +00:00
|
|
|
<>
|
|
|
|
<li className="list-inline-item">
|
|
|
|
<a
|
|
|
|
className="text-muted font-italic"
|
|
|
|
href={url}
|
|
|
|
title={url}
|
|
|
|
rel={relTags}
|
|
|
|
>
|
|
|
|
{hostname(url)}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li className="list-inline-item">•</li>
|
|
|
|
</>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
<li className="list-inline-item">
|
|
|
|
<span>
|
2022-06-21 21:42:29 +00:00
|
|
|
<MomentTime
|
|
|
|
published={post_view.post.published}
|
|
|
|
updated={post_view.post.updated}
|
|
|
|
/>
|
2020-09-06 16:15:25 +00:00
|
|
|
</span>
|
|
|
|
</li>
|
2023-01-04 16:56:24 +00:00
|
|
|
{body && (
|
|
|
|
<>
|
|
|
|
<li className="list-inline-item">•</li>
|
|
|
|
<li className="list-inline-item">
|
|
|
|
<button
|
|
|
|
className="text-muted btn btn-sm btn-link p-0"
|
|
|
|
data-tippy-content={mdNoImages.render(body)}
|
|
|
|
data-tippy-allowHtml={true}
|
|
|
|
onClick={linkEvent(this, this.handleShowBody)}
|
|
|
|
>
|
|
|
|
<Icon icon="book-open" classes="icon-inline mr-1" />
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
</>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
voteBar() {
|
|
|
|
return (
|
|
|
|
<div className={`vote-bar col-1 pr-0 small text-center`}>
|
|
|
|
<button
|
|
|
|
className={`btn-animate btn btn-link p-0 ${
|
2023-06-14 12:20:40 +00:00
|
|
|
this.postView.my_vote == 1 ? "text-info" : "text-muted"
|
2020-09-06 16:15:25 +00:00
|
|
|
}`}
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleUpvote)}
|
2021-02-22 02:39:04 +00:00
|
|
|
data-tippy-content={i18n.t("upvote")}
|
|
|
|
aria-label={i18n.t("upvote")}
|
2023-06-14 12:20:40 +00:00
|
|
|
aria-pressed={this.postView.my_vote === 1}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.upvoteLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<Icon icon="arrow-up1" classes="upvote" />
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
</button>
|
2021-04-09 16:23:30 +00:00
|
|
|
{showScores() ? (
|
|
|
|
<div
|
2023-06-16 17:12:07 +00:00
|
|
|
className={`unselectable pointer font-weight-bold text-muted px-1 post-score`}
|
2021-04-09 16:23:30 +00:00
|
|
|
data-tippy-content={this.pointsTippy}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{numToSI(this.postView.counts.score)}
|
2021-04-09 16:23:30 +00:00
|
|
|
</div>
|
|
|
|
) : (
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="p-1"></div>
|
2021-04-09 16:23:30 +00:00
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
{this.props.enableDownvotes && (
|
|
|
|
<button
|
|
|
|
className={`btn-animate btn btn-link p-0 ${
|
2023-06-14 12:20:40 +00:00
|
|
|
this.postView.my_vote == -1 ? "text-danger" : "text-muted"
|
2020-09-06 16:15:25 +00:00
|
|
|
}`}
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleDownvote)}
|
2021-02-22 02:39:04 +00:00
|
|
|
data-tippy-content={i18n.t("downvote")}
|
|
|
|
aria-label={i18n.t("downvote")}
|
2023-06-14 12:20:40 +00:00
|
|
|
aria-pressed={this.postView.my_vote === -1}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.downvoteLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<Icon icon="arrow-down1" classes="downvote" />
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-11-19 04:39:32 +00:00
|
|
|
get postLink() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView.post;
|
2022-11-19 04:39:32 +00:00
|
|
|
return (
|
|
|
|
<Link
|
2023-02-21 20:53:15 +00:00
|
|
|
className={`d-inline-block ${
|
2022-12-14 15:03:18 +00:00
|
|
|
!post.featured_community && !post.featured_local
|
|
|
|
? "text-body"
|
|
|
|
: "text-primary"
|
2023-02-21 20:53:15 +00:00
|
|
|
}`}
|
2022-11-19 04:39:32 +00:00
|
|
|
to={`/post/${post.id}`}
|
|
|
|
title={i18n.t("comments")}
|
|
|
|
>
|
2023-02-21 20:53:15 +00:00
|
|
|
<div
|
|
|
|
className="d-inline-block"
|
|
|
|
dangerouslySetInnerHTML={mdToHtmlInline(post.name)}
|
|
|
|
/>
|
2022-11-19 04:39:32 +00:00
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
postTitleLine() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView.post;
|
2023-06-05 21:31:12 +00:00
|
|
|
const url = post.url;
|
2023-01-04 16:56:24 +00:00
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<div className="post-title overflow-hidden">
|
|
|
|
<h5>
|
2023-01-04 16:56:24 +00:00
|
|
|
{url ? (
|
|
|
|
this.props.showBody ? (
|
|
|
|
<a
|
2023-02-21 20:53:15 +00:00
|
|
|
className={`d-inline-block ${
|
2023-01-04 16:56:24 +00:00
|
|
|
!post.featured_community && !post.featured_local
|
|
|
|
? "text-body"
|
|
|
|
: "text-primary"
|
2023-02-21 20:53:15 +00:00
|
|
|
}`}
|
2023-01-04 16:56:24 +00:00
|
|
|
href={url}
|
|
|
|
title={url}
|
|
|
|
rel={relTags}
|
|
|
|
>
|
2023-02-21 20:53:15 +00:00
|
|
|
<div
|
|
|
|
className="d-inline-block"
|
|
|
|
dangerouslySetInnerHTML={mdToHtmlInline(post.name)}
|
|
|
|
/>
|
2023-01-04 16:56:24 +00:00
|
|
|
</a>
|
|
|
|
) : (
|
|
|
|
this.postLink
|
|
|
|
)
|
|
|
|
) : (
|
|
|
|
this.postLink
|
2022-01-12 00:53:23 +00:00
|
|
|
)}
|
2023-01-04 16:56:24 +00:00
|
|
|
{(url && isImage(url)) ||
|
|
|
|
(post.thumbnail_url && (
|
|
|
|
<button
|
2023-02-21 20:53:15 +00:00
|
|
|
className="btn btn-link text-monospace text-muted small d-inline-block"
|
2023-01-04 16:56:24 +00:00
|
|
|
data-tippy-content={i18n.t("expand_here")}
|
|
|
|
onClick={linkEvent(this, this.handleImageExpandClick)}
|
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
icon={
|
|
|
|
!this.state.imageExpanded ? "plus-square" : "minus-square"
|
|
|
|
}
|
|
|
|
classes="icon-inline"
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
))}
|
2020-09-06 16:15:25 +00:00
|
|
|
{post.removed && (
|
|
|
|
<small className="ml-2 text-muted font-italic">
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("removed")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{post.deleted && (
|
|
|
|
<small
|
|
|
|
className="unselectable pointer ml-2 text-muted font-italic"
|
2021-02-22 02:39:04 +00:00
|
|
|
data-tippy-content={i18n.t("deleted")}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2021-02-11 20:35:27 +00:00
|
|
|
<Icon icon="trash" classes="icon-inline text-danger" />
|
2020-09-06 16:15:25 +00:00
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{post.locked && (
|
|
|
|
<small
|
|
|
|
className="unselectable pointer ml-2 text-muted font-italic"
|
2021-02-22 02:39:04 +00:00
|
|
|
data-tippy-content={i18n.t("locked")}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2021-02-11 20:35:27 +00:00
|
|
|
<Icon icon="lock" classes="icon-inline text-danger" />
|
2020-09-06 16:15:25 +00:00
|
|
|
</small>
|
|
|
|
)}
|
2022-12-14 15:03:18 +00:00
|
|
|
{post.featured_community && (
|
2020-09-06 16:15:25 +00:00
|
|
|
<small
|
|
|
|
className="unselectable pointer ml-2 text-muted font-italic"
|
2023-06-17 17:08:56 +00:00
|
|
|
aria-label={i18n.t("featured_in_community")}
|
|
|
|
data-tippy-content={i18n.t("featured_in_community")}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
2021-02-11 20:35:27 +00:00
|
|
|
<Icon icon="pin" classes="icon-inline text-primary" />
|
2020-09-06 16:15:25 +00:00
|
|
|
</small>
|
|
|
|
)}
|
2022-12-14 15:03:18 +00:00
|
|
|
{post.featured_local && (
|
|
|
|
<small
|
|
|
|
className="unselectable pointer ml-2 text-muted font-italic"
|
2023-06-17 17:08:56 +00:00
|
|
|
aria-label={i18n.t("featured_in_local")}
|
|
|
|
data-tippy-content={i18n.t("featured_in_local")}
|
2022-12-14 15:03:18 +00:00
|
|
|
>
|
|
|
|
<Icon icon="pin" classes="icon-inline text-secondary" />
|
|
|
|
</small>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
{post.nsfw && (
|
|
|
|
<small className="ml-2 text-muted font-italic">
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("nsfw")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
</h5>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
duplicatesLine() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const dupes = this.props.crossPosts;
|
2023-01-04 16:56:24 +00:00
|
|
|
return dupes && dupes.length > 0 ? (
|
|
|
|
<ul className="list-inline mb-1 small text-muted">
|
|
|
|
<>
|
|
|
|
<li className="list-inline-item mr-2">{i18n.t("cross_posted_to")}</li>
|
|
|
|
{dupes.map(pv => (
|
|
|
|
<li key={pv.post.id} className="list-inline-item mr-2">
|
|
|
|
<Link to={`/post/${pv.post.id}`}>
|
|
|
|
{pv.community.local
|
|
|
|
? pv.community.name
|
|
|
|
: `${pv.community.name}@${hostname(pv.community.actor_id)}`}
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
</ul>
|
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
);
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-12 00:53:23 +00:00
|
|
|
commentsLine(mobile = false) {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView.post;
|
2023-05-21 18:17:56 +00:00
|
|
|
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
2023-06-17 01:50:31 +00:00
|
|
|
<div className="d-flex align-items-center justify-content-start flex-wrap text-muted font-weight-bold mb-1">
|
2022-01-12 00:53:23 +00:00
|
|
|
{this.commentsButton}
|
2023-05-21 18:17:56 +00:00
|
|
|
{canShare() && (
|
|
|
|
<button
|
|
|
|
className="btn btn-link"
|
|
|
|
onClick={linkEvent(this, this.handleShare)}
|
|
|
|
type="button"
|
|
|
|
>
|
|
|
|
<Icon icon="share" inline />
|
|
|
|
</button>
|
|
|
|
)}
|
2022-02-17 18:28:43 +00:00
|
|
|
{!post.local && (
|
|
|
|
<a
|
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
|
|
|
title={i18n.t("link")}
|
|
|
|
href={post.ap_id}
|
|
|
|
>
|
|
|
|
<Icon icon="fedilink" inline />
|
|
|
|
</a>
|
|
|
|
)}
|
2022-02-02 14:56:43 +00:00
|
|
|
{mobile && !this.props.viewOnly && this.mobileVotes}
|
2023-01-04 16:56:24 +00:00
|
|
|
{UserService.Instance.myUserInfo &&
|
2022-02-02 14:56:43 +00:00
|
|
|
!this.props.viewOnly &&
|
|
|
|
this.postActions(mobile)}
|
2022-01-12 00:53:23 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-22 02:24:09 +00:00
|
|
|
postActions(mobile = false) {
|
2022-01-12 00:53:23 +00:00
|
|
|
// Possible enhancement: Priority+ pattern instead of just hard coding which get hidden behind the show more button.
|
|
|
|
// Possible enhancement: Make each button a component.
|
2023-06-14 12:20:40 +00:00
|
|
|
const post_view = this.postView;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2022-01-12 00:53:23 +00:00
|
|
|
<>
|
|
|
|
{this.saveButton}
|
|
|
|
{this.crossPostButton}
|
|
|
|
{mobile && this.showMoreButton}
|
|
|
|
{(!mobile || this.state.showAdvanced) && (
|
|
|
|
<>
|
|
|
|
{!this.myPost && (
|
|
|
|
<>
|
|
|
|
{this.reportButton}
|
|
|
|
{this.blockButton}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{this.myPost && (this.showBody || this.state.showAdvanced) && (
|
|
|
|
<>
|
|
|
|
{this.editButton}
|
|
|
|
{this.deleteButton}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{this.state.showAdvanced && (
|
|
|
|
<>
|
2023-01-04 16:56:24 +00:00
|
|
|
{this.showBody && post_view.post.body && this.viewSourceButton}
|
2023-02-21 20:53:51 +00:00
|
|
|
{/* Any mod can do these, not limited to hierarchy*/}
|
|
|
|
{(amMod(this.props.moderators) || amAdmin()) && (
|
2022-01-12 00:53:23 +00:00
|
|
|
<>
|
|
|
|
{this.lockButton}
|
2022-12-14 15:03:18 +00:00
|
|
|
{this.featureButton}
|
2022-01-12 00:53:23 +00:00
|
|
|
</>
|
|
|
|
)}
|
2022-06-21 21:42:29 +00:00
|
|
|
{(this.canMod_ || this.canAdmin_) && <>{this.modRemoveButton}</>}
|
2022-01-12 00:53:23 +00:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{!mobile && this.showMoreButton}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get commentsButton() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post_view = this.postView;
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
2023-06-12 08:30:37 +00:00
|
|
|
<Link
|
|
|
|
className="btn btn-link text-muted py-0 pl-0 text-muted"
|
|
|
|
title={i18n.t("number_of_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", {
|
2023-05-11 18:32:32 +00:00
|
|
|
count: Number(post_view.counts.comments),
|
2023-06-12 08:30:37 +00:00
|
|
|
formattedCount: numToSI(post_view.counts.comments),
|
2022-01-12 00:53:23 +00:00
|
|
|
})}
|
2023-06-12 08:30:37 +00:00
|
|
|
</span>
|
|
|
|
{this.unreadCount && (
|
|
|
|
<span className="small text-warning">
|
|
|
|
({this.unreadCount} {i18n.t("new")})
|
2022-09-27 19:42:24 +00:00
|
|
|
</span>
|
2023-06-12 08:30:37 +00:00
|
|
|
)}
|
|
|
|
</Link>
|
2022-01-12 00:53:23 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-05-15 19:53:29 +00:00
|
|
|
get unreadCount(): number | undefined {
|
2023-06-14 12:20:40 +00:00
|
|
|
const pv = this.postView;
|
2023-05-15 19:53:29 +00:00
|
|
|
return pv.unread_comments == pv.counts.comments || pv.unread_comments == 0
|
2023-01-04 16:56:24 +00:00
|
|
|
? undefined
|
|
|
|
: pv.unread_comments;
|
2022-09-27 19:42:24 +00:00
|
|
|
}
|
|
|
|
|
2022-01-12 00:53:23 +00:00
|
|
|
get mobileVotes() {
|
|
|
|
// TODO: make nicer
|
2023-06-05 21:31:12 +00:00
|
|
|
const tippy = showScores()
|
|
|
|
? { "data-tippy-content": this.pointsTippy }
|
|
|
|
: {};
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div>
|
|
|
|
<button
|
|
|
|
className={`btn-animate btn py-0 px-1 ${
|
2023-06-14 12:20:40 +00:00
|
|
|
this.postView.my_vote === 1 ? "text-info" : "text-muted"
|
2022-01-12 00:53:23 +00:00
|
|
|
}`}
|
|
|
|
{...tippy}
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleUpvote)}
|
2022-01-12 00:53:23 +00:00
|
|
|
aria-label={i18n.t("upvote")}
|
2023-06-14 12:20:40 +00:00
|
|
|
aria-pressed={this.postView.my_vote === 1}
|
2022-01-12 00:53:23 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.upvoteLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<Icon icon="arrow-up1" classes="icon-inline small" />
|
|
|
|
{showScores() && (
|
|
|
|
<span className="ml-2">
|
|
|
|
{numToSI(this.postView.counts.upvotes)}
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</>
|
2022-01-12 00:53:23 +00:00
|
|
|
)}
|
|
|
|
</button>
|
|
|
|
{this.props.enableDownvotes && (
|
|
|
|
<button
|
|
|
|
className={`ml-2 btn-animate btn py-0 px-1 ${
|
2023-06-14 12:20:40 +00:00
|
|
|
this.postView.my_vote === -1 ? "text-danger" : "text-muted"
|
2022-01-12 00:53:23 +00:00
|
|
|
}`}
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleDownvote)}
|
2022-01-12 00:53:23 +00:00
|
|
|
{...tippy}
|
|
|
|
aria-label={i18n.t("downvote")}
|
2023-06-14 12:20:40 +00:00
|
|
|
aria-pressed={this.postView.my_vote === -1}
|
2022-01-12 00:53:23 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.downvoteLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<Icon icon="arrow-down1" classes="icon-inline small" />
|
|
|
|
{showScores() && (
|
|
|
|
<span
|
|
|
|
className={classNames("ml-2", {
|
|
|
|
invisible: this.postView.counts.downvotes === 0,
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{numToSI(this.postView.counts.downvotes)}
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</>
|
2020-09-26 16:18:49 +00:00
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get saveButton() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const saved = this.postView.saved;
|
2023-06-05 21:31:12 +00:00
|
|
|
const label = saved ? i18n.t("unsave") : i18n.t("save");
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleSavePostClick)}
|
|
|
|
data-tippy-content={label}
|
|
|
|
aria-label={label}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.saveLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<Icon
|
|
|
|
icon="star"
|
|
|
|
classes={classNames({ "text-warning": saved })}
|
|
|
|
inline
|
|
|
|
/>
|
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get crossPostButton() {
|
|
|
|
return (
|
|
|
|
<Link
|
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2023-04-15 14:47:10 +00:00
|
|
|
to={{
|
|
|
|
/* Empty string properties are required to satisfy type*/
|
|
|
|
pathname: "/create_post",
|
|
|
|
state: { ...this.crossPostParams },
|
|
|
|
hash: "",
|
|
|
|
key: "",
|
|
|
|
search: "",
|
|
|
|
}}
|
2022-01-12 00:53:23 +00:00
|
|
|
title={i18n.t("cross_post")}
|
2023-06-14 14:03:00 +00:00
|
|
|
data-tippy-content={i18n.t("cross_post")}
|
|
|
|
aria-label={i18n.t("cross_post")}
|
2022-01-12 00:53:23 +00:00
|
|
|
>
|
|
|
|
<Icon icon="copy" inline />
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get reportButton() {
|
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleShowReportDialog)}
|
|
|
|
data-tippy-content={i18n.t("show_report_dialog")}
|
|
|
|
aria-label={i18n.t("show_report_dialog")}
|
|
|
|
>
|
|
|
|
<Icon icon="flag" inline />
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get blockButton() {
|
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2023-06-14 12:20:40 +00:00
|
|
|
onClick={linkEvent(this, this.handleBlockPersonClick)}
|
2022-01-12 00:53:23 +00:00
|
|
|
data-tippy-content={i18n.t("block_user")}
|
|
|
|
aria-label={i18n.t("block_user")}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.blockLoading ? <Spinner /> : <Icon icon="slash" inline />}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get editButton() {
|
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleEditClick)}
|
|
|
|
data-tippy-content={i18n.t("edit")}
|
|
|
|
aria-label={i18n.t("edit")}
|
|
|
|
>
|
|
|
|
<Icon icon="edit" inline />
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get deleteButton() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const deleted = this.postView.post.deleted;
|
2023-06-05 21:31:12 +00:00
|
|
|
const label = !deleted ? i18n.t("delete") : i18n.t("restore");
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleDeleteClick)}
|
|
|
|
data-tippy-content={label}
|
|
|
|
aria-label={label}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.deleteLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<Icon
|
|
|
|
icon="trash"
|
|
|
|
classes={classNames({ "text-danger": deleted })}
|
|
|
|
inline
|
|
|
|
/>
|
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get showMoreButton() {
|
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleShowAdvanced)}
|
|
|
|
data-tippy-content={i18n.t("more")}
|
|
|
|
aria-label={i18n.t("more")}
|
|
|
|
>
|
|
|
|
<Icon icon="more-vertical" inline />
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get viewSourceButton() {
|
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleViewSource)}
|
|
|
|
data-tippy-content={i18n.t("view_source")}
|
|
|
|
aria-label={i18n.t("view_source")}
|
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
icon="file-text"
|
|
|
|
classes={classNames({ "text-success": this.state.viewSource })}
|
|
|
|
inline
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get lockButton() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const locked = this.postView.post.locked;
|
2023-06-05 21:31:12 +00:00
|
|
|
const label = locked ? i18n.t("unlock") : i18n.t("lock");
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleModLock)}
|
|
|
|
data-tippy-content={label}
|
|
|
|
aria-label={label}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.lockLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<Icon
|
|
|
|
icon="lock"
|
|
|
|
classes={classNames({ "text-danger": locked })}
|
|
|
|
inline
|
|
|
|
/>
|
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-14 15:03:18 +00:00
|
|
|
get featureButton() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const featuredCommunity = this.postView.post.featured_community;
|
2023-02-21 20:53:51 +00:00
|
|
|
const labelCommunity = featuredCommunity
|
2022-12-14 15:03:18 +00:00
|
|
|
? i18n.t("unfeature_from_community")
|
|
|
|
: i18n.t("feature_in_community");
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
const featuredLocal = this.postView.post.featured_local;
|
2023-02-21 20:53:51 +00:00
|
|
|
const labelLocal = featuredLocal
|
2022-12-14 15:03:18 +00:00
|
|
|
? i18n.t("unfeature_from_local")
|
|
|
|
: i18n.t("feature_in_local");
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
2022-12-14 15:03:18 +00:00
|
|
|
<span>
|
|
|
|
<button
|
|
|
|
className="btn btn-link btn-animate text-muted py-0 pl-0"
|
2023-02-21 20:53:51 +00:00
|
|
|
onClick={linkEvent(this, this.handleModFeaturePostCommunity)}
|
|
|
|
data-tippy-content={labelCommunity}
|
|
|
|
aria-label={labelCommunity}
|
2022-12-14 15:03:18 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.featureCommunityLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<span>
|
|
|
|
<Icon
|
|
|
|
icon="pin"
|
|
|
|
classes={classNames({ "text-success": featuredCommunity })}
|
|
|
|
inline
|
|
|
|
/>
|
|
|
|
{i18n.t("community")}
|
|
|
|
</span>
|
|
|
|
)}
|
2022-12-14 15:03:18 +00:00
|
|
|
</button>
|
2023-02-21 20:53:51 +00:00
|
|
|
{amAdmin() && (
|
2022-12-14 15:03:18 +00:00
|
|
|
<button
|
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2023-02-21 20:53:51 +00:00
|
|
|
onClick={linkEvent(this, this.handleModFeaturePostLocal)}
|
|
|
|
data-tippy-content={labelLocal}
|
|
|
|
aria-label={labelLocal}
|
2022-12-14 15:03:18 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.featureLocalLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<span>
|
|
|
|
<Icon
|
|
|
|
icon="pin"
|
|
|
|
classes={classNames({ "text-success": featuredLocal })}
|
|
|
|
inline
|
|
|
|
/>
|
|
|
|
{i18n.t("local")}
|
|
|
|
</span>
|
|
|
|
)}
|
2022-12-14 15:03:18 +00:00
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</span>
|
2022-01-12 00:53:23 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get modRemoveButton() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const removed = this.postView.post.removed;
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
!removed ? this.handleModRemoveShow : this.handleModRemoveSubmit
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{/* TODO: Find an icon for this. */}
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.removeLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : !removed ? (
|
|
|
|
i18n.t("remove")
|
|
|
|
) : (
|
|
|
|
i18n.t("restore")
|
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mod/Admin actions to be taken against the author.
|
|
|
|
*/
|
|
|
|
userActionsLine() {
|
|
|
|
// TODO: make nicer
|
2023-06-14 12:20:40 +00:00
|
|
|
const post_view = this.postView;
|
2022-01-12 00:53:23 +00:00
|
|
|
return (
|
|
|
|
this.state.showAdvanced && (
|
|
|
|
<>
|
2022-06-21 21:42:29 +00:00
|
|
|
{this.canMod_ && (
|
2022-01-12 00:53:23 +00:00
|
|
|
<>
|
2022-06-21 21:42:29 +00:00
|
|
|
{!this.creatorIsMod_ &&
|
2022-01-12 00:53:23 +00:00
|
|
|
(!post_view.creator_banned_from_community ? (
|
2021-09-28 10:38:59 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleModBanFromCommunityShow
|
|
|
|
)}
|
2023-02-21 21:12:00 +00:00
|
|
|
aria-label={i18n.t("ban_from_community")}
|
2021-09-28 10:38:59 +00:00
|
|
|
>
|
2023-02-21 21:12:00 +00:00
|
|
|
{i18n.t("ban_from_community")}
|
2021-09-28 10:38:59 +00:00
|
|
|
</button>
|
2022-01-12 00:53:23 +00:00
|
|
|
) : (
|
2021-09-28 10:38:59 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleModBanFromCommunitySubmit
|
|
|
|
)}
|
|
|
|
aria-label={i18n.t("unban")}
|
2021-09-28 10:38:59 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.banLoading ? <Spinner /> : i18n.t("unban")}
|
2021-09-28 10:38:59 +00:00
|
|
|
</button>
|
2022-01-12 00:53:23 +00:00
|
|
|
))}
|
|
|
|
{!post_view.creator_banned_from_community && (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleAddModToCommunity)}
|
|
|
|
aria-label={
|
2022-06-21 21:42:29 +00:00
|
|
|
this.creatorIsMod_
|
2022-01-12 00:53:23 +00:00
|
|
|
? i18n.t("remove_as_mod")
|
|
|
|
: i18n.t("appoint_as_mod")
|
|
|
|
}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.addModLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : this.creatorIsMod_ ? (
|
|
|
|
i18n.t("remove_as_mod")
|
|
|
|
) : (
|
|
|
|
i18n.t("appoint_as_mod")
|
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
2021-08-20 02:56:18 +00:00
|
|
|
)}
|
2020-09-26 16:18:49 +00:00
|
|
|
</>
|
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
{/* Community creators and admins can transfer community to another mod */}
|
2023-01-04 16:56:24 +00:00
|
|
|
{(amCommunityCreator(post_view.creator.id, this.props.moderators) ||
|
2022-06-21 21:42:29 +00:00
|
|
|
this.canAdmin_) &&
|
|
|
|
this.creatorIsMod_ &&
|
2022-01-12 00:53:23 +00:00
|
|
|
(!this.state.showConfirmTransferCommunity ? (
|
2020-09-26 16:18:49 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleShowConfirmTransferCommunity
|
|
|
|
)}
|
|
|
|
aria-label={i18n.t("transfer_community")}
|
2020-09-26 16:18:49 +00:00
|
|
|
>
|
2022-01-12 00:53:23 +00:00
|
|
|
{i18n.t("transfer_community")}
|
2020-09-26 16:18:49 +00:00
|
|
|
</button>
|
2022-01-12 00:53:23 +00:00
|
|
|
) : (
|
|
|
|
<>
|
2020-09-26 16:18:49 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="d-inline-block mr-1 btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
aria-label={i18n.t("are_you_sure")}
|
2020-09-26 16:18:49 +00:00
|
|
|
>
|
2022-01-12 00:53:23 +00:00
|
|
|
{i18n.t("are_you_sure")}
|
2020-09-26 16:18:49 +00:00
|
|
|
</button>
|
2022-01-12 00:53:23 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0 d-inline-block mr-1"
|
2022-01-12 00:53:23 +00:00
|
|
|
aria-label={i18n.t("yes")}
|
|
|
|
onClick={linkEvent(this, this.handleTransferCommunity)}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.transferLoading ? <Spinner /> : i18n.t("yes")}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0 d-inline-block"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleCancelShowConfirmTransferCommunity
|
2021-03-25 16:44:16 +00:00
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
aria-label={i18n.t("no")}
|
|
|
|
>
|
|
|
|
{i18n.t("no")}
|
|
|
|
</button>
|
|
|
|
</>
|
|
|
|
))}
|
|
|
|
{/* Admins can ban from all, and appoint other admins */}
|
2022-06-21 21:42:29 +00:00
|
|
|
{this.canAdmin_ && (
|
2022-01-12 00:53:23 +00:00
|
|
|
<>
|
2022-06-23 19:44:05 +00:00
|
|
|
{!this.creatorIsAdmin_ && (
|
|
|
|
<>
|
|
|
|
{!isBanned(post_view.creator) ? (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-06-23 19:44:05 +00:00
|
|
|
onClick={linkEvent(this, this.handleModBanShow)}
|
|
|
|
aria-label={i18n.t("ban_from_site")}
|
|
|
|
>
|
|
|
|
{i18n.t("ban_from_site")}
|
|
|
|
</button>
|
|
|
|
) : (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-06-23 19:44:05 +00:00
|
|
|
onClick={linkEvent(this, this.handleModBanSubmit)}
|
|
|
|
aria-label={i18n.t("unban_from_site")}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.banLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
i18n.t("unban_from_site")
|
|
|
|
)}
|
2022-06-23 19:44:05 +00:00
|
|
|
</button>
|
|
|
|
)}
|
2020-10-13 20:12:40 +00:00
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-06-23 19:44:05 +00:00
|
|
|
onClick={linkEvent(this, this.handlePurgePersonShow)}
|
|
|
|
aria-label={i18n.t("purge_user")}
|
2020-09-26 16:18:49 +00:00
|
|
|
>
|
2022-06-23 19:44:05 +00:00
|
|
|
{i18n.t("purge_user")}
|
2020-10-13 20:12:40 +00:00
|
|
|
</button>
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-06-23 19:44:05 +00:00
|
|
|
onClick={linkEvent(this, this.handlePurgePostShow)}
|
|
|
|
aria-label={i18n.t("purge_post")}
|
2020-09-26 16:18:49 +00:00
|
|
|
>
|
2022-06-23 19:44:05 +00:00
|
|
|
{i18n.t("purge_post")}
|
2020-10-13 20:12:40 +00:00
|
|
|
</button>
|
2022-06-23 19:44:05 +00:00
|
|
|
</>
|
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
{!isBanned(post_view.creator) && post_view.creator.local && (
|
|
|
|
<button
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-link btn-animate text-muted py-0"
|
2022-01-12 00:53:23 +00:00
|
|
|
onClick={linkEvent(this, this.handleAddAdmin)}
|
|
|
|
aria-label={
|
2022-06-21 21:42:29 +00:00
|
|
|
this.creatorIsAdmin_
|
2022-01-12 00:53:23 +00:00
|
|
|
? i18n.t("remove_as_admin")
|
|
|
|
: i18n.t("appoint_as_admin")
|
|
|
|
}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.addAdminLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : this.creatorIsAdmin_ ? (
|
|
|
|
i18n.t("remove_as_admin")
|
|
|
|
) : (
|
|
|
|
i18n.t("appoint_as_admin")
|
|
|
|
)}
|
2022-01-12 00:53:23 +00:00
|
|
|
</button>
|
|
|
|
)}
|
2020-09-26 16:18:49 +00:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)
|
2020-09-06 16:15:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
removeAndBanDialogs() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView;
|
2023-06-05 21:31:12 +00:00
|
|
|
const purgeTypeText =
|
2023-01-04 16:56:24 +00:00
|
|
|
this.state.purgeType == PurgeType.Post
|
|
|
|
? i18n.t("purge_post")
|
|
|
|
: `${i18n.t("purge")} ${post.creator.name}`;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{this.state.showRemoveDialog && (
|
|
|
|
<form
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-inline"
|
2020-09-06 16:15:25 +00:00
|
|
|
onSubmit={linkEvent(this, this.handleModRemoveSubmit)}
|
|
|
|
>
|
2022-09-22 15:03:35 +00:00
|
|
|
<label className="sr-only" htmlFor="post-listing-remove-reason">
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("reason")}
|
2021-02-09 16:21:24 +00:00
|
|
|
</label>
|
2020-09-06 16:15:25 +00:00
|
|
|
<input
|
|
|
|
type="text"
|
2021-02-09 16:21:24 +00:00
|
|
|
id="post-listing-remove-reason"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-control mr-2"
|
2021-02-22 02:39:04 +00:00
|
|
|
placeholder={i18n.t("reason")}
|
2023-01-04 16:56:24 +00:00
|
|
|
value={this.state.removeReason}
|
2020-09-06 16:15:25 +00:00
|
|
|
onInput={linkEvent(this, this.handleModRemoveReasonChange)}
|
|
|
|
/>
|
2021-02-09 16:21:24 +00:00
|
|
|
<button
|
|
|
|
type="submit"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-secondary"
|
2021-02-22 02:39:04 +00:00
|
|
|
aria-label={i18n.t("remove_post")}
|
2021-02-09 16:21:24 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.removeLoading ? <Spinner /> : i18n.t("remove_post")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
)}
|
|
|
|
{this.state.showBanDialog && (
|
|
|
|
<form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="form-group row col-12">
|
|
|
|
<label
|
|
|
|
className="col-form-label"
|
|
|
|
htmlFor="post-listing-ban-reason"
|
|
|
|
>
|
2021-02-22 02:39:04 +00:00
|
|
|
{i18n.t("reason")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
2021-02-09 16:21:24 +00:00
|
|
|
id="post-listing-ban-reason"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-control mr-2"
|
2021-02-22 02:39:04 +00:00
|
|
|
placeholder={i18n.t("reason")}
|
2023-01-04 16:56:24 +00:00
|
|
|
value={this.state.banReason}
|
2020-09-06 16:15:25 +00:00
|
|
|
onInput={linkEvent(this, this.handleModBanReasonChange)}
|
|
|
|
/>
|
2022-09-22 15:03:35 +00:00
|
|
|
<label className="col-form-label" htmlFor={`mod-ban-expires`}>
|
2022-01-09 17:53:11 +00:00
|
|
|
{i18n.t("expires")}
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
type="number"
|
|
|
|
id={`mod-ban-expires`}
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-control mr-2"
|
2022-01-09 17:53:11 +00:00
|
|
|
placeholder={i18n.t("number_of_days")}
|
2023-01-04 16:56:24 +00:00
|
|
|
value={this.state.banExpireDays}
|
2022-01-09 17:53:11 +00:00
|
|
|
onInput={linkEvent(this, this.handleModBanExpireDaysChange)}
|
|
|
|
/>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="form-group">
|
|
|
|
<div className="form-check">
|
2020-09-06 16:15:25 +00:00
|
|
|
<input
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-check-input"
|
2020-09-06 16:15:25 +00:00
|
|
|
id="mod-ban-remove-data"
|
|
|
|
type="checkbox"
|
|
|
|
checked={this.state.removeData}
|
|
|
|
onChange={linkEvent(this, this.handleModRemoveDataChange)}
|
|
|
|
/>
|
2021-08-17 21:46:27 +00:00
|
|
|
<label
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-check-label"
|
2021-08-17 21:46:27 +00:00
|
|
|
htmlFor="mod-ban-remove-data"
|
|
|
|
title={i18n.t("remove_content_more")}
|
|
|
|
>
|
|
|
|
{i18n.t("remove_content")}
|
2020-09-06 16:15:25 +00:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/* TODO hold off on expires until later */}
|
|
|
|
{/* <div class="form-group row"> */}
|
|
|
|
{/* <label class="col-form-label">Expires</label> */}
|
|
|
|
{/* <input type="date" class="form-control mr-2" placeholder={i18n.t('expires')} value={this.state.banExpires} onInput={linkEvent(this, this.handleModBanExpiresChange)} /> */}
|
|
|
|
{/* </div> */}
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="form-group row">
|
2021-02-09 16:21:24 +00:00
|
|
|
<button
|
|
|
|
type="submit"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-secondary"
|
2021-02-22 02:39:04 +00:00
|
|
|
aria-label={i18n.t("ban")}
|
2021-02-09 16:21:24 +00:00
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.banLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<span>
|
|
|
|
{i18n.t("ban")} {post.creator.name}
|
|
|
|
</span>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
)}
|
2021-09-28 10:38:59 +00:00
|
|
|
{this.state.showReportDialog && (
|
|
|
|
<form
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-inline"
|
2021-09-28 10:38:59 +00:00
|
|
|
onSubmit={linkEvent(this, this.handleReportSubmit)}
|
|
|
|
>
|
2022-09-22 15:03:35 +00:00
|
|
|
<label className="sr-only" htmlFor="post-report-reason">
|
2021-09-28 10:38:59 +00:00
|
|
|
{i18n.t("reason")}
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="post-report-reason"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-control mr-2"
|
2021-09-28 10:38:59 +00:00
|
|
|
placeholder={i18n.t("reason")}
|
|
|
|
required
|
2023-01-04 16:56:24 +00:00
|
|
|
value={this.state.reportReason}
|
2021-09-28 10:38:59 +00:00
|
|
|
onInput={linkEvent(this, this.handleReportReasonChange)}
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
type="submit"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-secondary"
|
2021-09-28 10:38:59 +00:00
|
|
|
aria-label={i18n.t("create_report")}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.reportLoading ? <Spinner /> : i18n.t("create_report")}
|
2021-09-28 10:38:59 +00:00
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
)}
|
2022-06-23 19:44:05 +00:00
|
|
|
{this.state.showPurgeDialog && (
|
|
|
|
<form
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-inline"
|
2022-06-23 19:44:05 +00:00
|
|
|
onSubmit={linkEvent(this, this.handlePurgeSubmit)}
|
|
|
|
>
|
|
|
|
<PurgeWarning />
|
2022-09-22 15:03:35 +00:00
|
|
|
<label className="sr-only" htmlFor="purge-reason">
|
2022-06-23 19:44:05 +00:00
|
|
|
{i18n.t("reason")}
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="purge-reason"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="form-control mr-2"
|
2022-06-23 19:44:05 +00:00
|
|
|
placeholder={i18n.t("reason")}
|
2023-01-04 16:56:24 +00:00
|
|
|
value={this.state.purgeReason}
|
2022-06-23 19:44:05 +00:00
|
|
|
onInput={linkEvent(this, this.handlePurgeReasonChange)}
|
|
|
|
/>
|
|
|
|
{this.state.purgeLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<button
|
|
|
|
type="submit"
|
2022-09-22 15:03:35 +00:00
|
|
|
className="btn btn-secondary"
|
2022-06-23 19:44:05 +00:00
|
|
|
aria-label={purgeTypeText}
|
|
|
|
>
|
2023-06-14 12:20:40 +00:00
|
|
|
{this.state.purgeLoading ? <Spinner /> : { purgeTypeText }}
|
2022-06-23 19:44:05 +00:00
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</form>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
mobileThumbnail() {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView.post;
|
2023-01-04 16:56:24 +00:00
|
|
|
return post.thumbnail_url || (post.url && isImage(post.url)) ? (
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="row">
|
2021-02-22 02:39:04 +00:00
|
|
|
<div className={`${this.state.imageExpanded ? "col-12" : "col-8"}`}>
|
2020-09-06 16:15:25 +00:00
|
|
|
{this.postTitleLine()}
|
|
|
|
</div>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="col-4">
|
2020-09-06 16:15:25 +00:00
|
|
|
{/* Post body prev or thumbnail */}
|
|
|
|
{!this.state.imageExpanded && this.thumbnail()}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
this.postTitleLine()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
showMobilePreview() {
|
2023-06-15 17:21:42 +00:00
|
|
|
const { body, id } = this.postView.post;
|
|
|
|
|
2023-01-04 16:56:24 +00:00
|
|
|
return !this.showBody && body ? (
|
2023-06-15 17:21:42 +00:00
|
|
|
<Link className="text-body" to={`/post/${id}`}>
|
|
|
|
<div className="md-div mb-1 preview-lines">{body}</div>
|
|
|
|
</Link>
|
2023-01-04 16:56:24 +00:00
|
|
|
) : (
|
|
|
|
<></>
|
2020-09-06 16:15:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
listing() {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{/* The mobile view*/}
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="d-block d-sm-none">
|
2023-06-16 20:27:41 +00:00
|
|
|
<article className="row post-container">
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="col-12">
|
2020-09-06 16:15:25 +00:00
|
|
|
{this.createdLine()}
|
|
|
|
|
|
|
|
{/* If it has a thumbnail, do a right aligned thumbnail */}
|
|
|
|
{this.mobileThumbnail()}
|
|
|
|
|
|
|
|
{/* Show a preview of the post body */}
|
|
|
|
{this.showMobilePreview()}
|
|
|
|
|
|
|
|
{this.commentsLine(true)}
|
2022-01-12 00:53:23 +00:00
|
|
|
{this.userActionsLine()}
|
2020-09-06 16:15:25 +00:00
|
|
|
{this.duplicatesLine()}
|
|
|
|
{this.removeAndBanDialogs()}
|
|
|
|
</div>
|
2023-06-16 20:27:41 +00:00
|
|
|
</article>
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* The larger view*/}
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="d-none d-sm-block">
|
2023-06-16 20:27:41 +00:00
|
|
|
<article className="row post-container">
|
2022-02-02 14:56:43 +00:00
|
|
|
{!this.props.viewOnly && this.voteBar()}
|
2023-06-16 17:12:07 +00:00
|
|
|
<div className="col-sm-2 pr-0 post-media">
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="">{this.thumbnail()}</div>
|
2022-01-12 00:53:23 +00:00
|
|
|
</div>
|
2022-09-22 15:03:35 +00:00
|
|
|
<div className="col-12 col-sm-9">
|
|
|
|
<div className="row">
|
2020-09-06 16:15:25 +00:00
|
|
|
<div className="col-12">
|
|
|
|
{this.postTitleLine()}
|
|
|
|
{this.createdLine()}
|
|
|
|
{this.commentsLine()}
|
|
|
|
{this.duplicatesLine()}
|
2022-01-12 00:53:23 +00:00
|
|
|
{this.userActionsLine()}
|
2020-09-06 16:15:25 +00:00
|
|
|
{this.removeAndBanDialogs()}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-06-16 20:27:41 +00:00
|
|
|
</article>
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private get myPost(): boolean {
|
2023-01-04 16:56:24 +00:00
|
|
|
return (
|
2023-06-14 12:20:40 +00:00
|
|
|
this.postView.creator.id ==
|
2023-01-04 16:56:24 +00:00
|
|
|
UserService.Instance.myUserInfo?.local_user_view.person.id
|
|
|
|
);
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
handleEditClick(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showEdit: true });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleEditCancel() {
|
2022-09-22 15:03:35 +00:00
|
|
|
this.setState({ showEdit: false });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-06-12 14:05:36 +00:00
|
|
|
// The actual editing is done in the receive for post
|
2023-06-14 12:20:40 +00:00
|
|
|
handleEditPost(form: EditPost) {
|
2022-09-22 15:03:35 +00:00
|
|
|
this.setState({ showEdit: false });
|
2023-06-14 12:20:40 +00:00
|
|
|
this.props.onPostEdit(form);
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-05-21 18:17:56 +00:00
|
|
|
handleShare(i: PostListing) {
|
|
|
|
const { name, body, id } = i.props.post_view.post;
|
|
|
|
share({
|
|
|
|
title: name,
|
|
|
|
text: body?.slice(0, 50),
|
|
|
|
url: `${getHttpBase()}/post/${id}`,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-09-28 10:38:59 +00:00
|
|
|
handleShowReportDialog(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showReportDialog: !i.state.showReportDialog });
|
2021-09-28 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleReportReasonChange(i: PostListing, event: any) {
|
2023-01-04 16:56:24 +00:00
|
|
|
i.setState({ reportReason: event.target.value });
|
2021-09-28 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleReportSubmit(i: PostListing, event: any) {
|
|
|
|
event.preventDefault();
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ reportLoading: true });
|
|
|
|
i.props.onPostReport({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
reason: i.state.reportReason ?? "",
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2021-09-28 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
handleBlockPersonClick(i: PostListing) {
|
|
|
|
i.setState({ blockLoading: true });
|
|
|
|
i.props.onBlockPerson({
|
|
|
|
person_id: i.postView.creator.id,
|
|
|
|
block: true,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2021-08-20 02:56:18 +00:00
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
handleDeleteClick(i: PostListing) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ deleteLoading: true });
|
|
|
|
i.props.onDeletePost({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
deleted: !i.postView.post.deleted,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleSavePostClick(i: PostListing) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ saveLoading: true });
|
|
|
|
i.props.onSavePost({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
save: !i.postView.saved,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-04-15 14:47:10 +00:00
|
|
|
get crossPostParams(): PostFormParams {
|
|
|
|
const queryParams: PostFormParams = {};
|
2023-06-14 12:20:40 +00:00
|
|
|
const { name, url } = this.postView.post;
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2023-04-15 14:47:10 +00:00
|
|
|
queryParams.name = name;
|
|
|
|
|
|
|
|
if (url) {
|
|
|
|
queryParams.url = url;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
2023-04-15 14:47:10 +00:00
|
|
|
|
|
|
|
const crossPostBody = this.crossPostBody();
|
2023-01-04 16:56:24 +00:00
|
|
|
if (crossPostBody) {
|
2023-04-15 14:47:10 +00:00
|
|
|
queryParams.body = crossPostBody;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
2023-04-15 14:47:10 +00:00
|
|
|
|
|
|
|
return queryParams;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-01-04 16:56:24 +00:00
|
|
|
crossPostBody(): string | undefined {
|
2023-06-14 12:20:40 +00:00
|
|
|
const post = this.postView.post;
|
2023-06-05 21:31:12 +00:00
|
|
|
const body = post.body;
|
2023-01-04 16:56:24 +00:00
|
|
|
|
|
|
|
return body
|
|
|
|
? `${i18n.t("cross_posted_from")} ${post.ap_id}\n\n${body.replace(
|
|
|
|
/^/gm,
|
|
|
|
"> "
|
|
|
|
)}`
|
|
|
|
: undefined;
|
2021-03-25 17:28:47 +00:00
|
|
|
}
|
|
|
|
|
2021-03-25 16:44:16 +00:00
|
|
|
get showBody(): boolean {
|
|
|
|
return this.props.showBody || this.state.showBody;
|
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
handleModRemoveShow(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({
|
|
|
|
showRemoveDialog: !i.state.showRemoveDialog,
|
|
|
|
showBanDialog: false,
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveReasonChange(i: PostListing, event: any) {
|
2023-01-04 16:56:24 +00:00
|
|
|
i.setState({ removeReason: event.target.value });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveDataChange(i: PostListing, event: any) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ removeData: event.target.checked });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-01-26 17:21:10 +00:00
|
|
|
handleModRemoveSubmit(i: PostListing, event: any) {
|
2020-09-06 16:15:25 +00:00
|
|
|
event.preventDefault();
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ removeLoading: true });
|
|
|
|
i.props.onRemovePost({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
removed: !i.postView.post.removed,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleModLock(i: PostListing) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ lockLoading: true });
|
|
|
|
i.props.onLockPost({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
locked: !i.postView.post.locked,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 20:53:51 +00:00
|
|
|
handleModFeaturePostLocal(i: PostListing) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ featureLocalLoading: true });
|
|
|
|
i.props.onFeaturePost({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
featured: !i.postView.post.featured_local,
|
|
|
|
feature_type: "Local",
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2023-02-21 20:53:51 +00:00
|
|
|
}
|
2023-01-04 16:56:24 +00:00
|
|
|
|
2023-02-21 20:53:51 +00:00
|
|
|
handleModFeaturePostCommunity(i: PostListing) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ featureCommunityLoading: true });
|
|
|
|
i.props.onFeaturePost({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
featured: !i.postView.post.featured_community,
|
|
|
|
feature_type: "Community",
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanFromCommunityShow(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({
|
|
|
|
showBanDialog: true,
|
|
|
|
banType: BanType.Community,
|
|
|
|
showRemoveDialog: false,
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanShow(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({
|
|
|
|
showBanDialog: true,
|
|
|
|
banType: BanType.Site,
|
|
|
|
showRemoveDialog: false,
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-06-23 19:44:05 +00:00
|
|
|
handlePurgePersonShow(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({
|
|
|
|
showPurgeDialog: true,
|
|
|
|
purgeType: PurgeType.Person,
|
|
|
|
showRemoveDialog: false,
|
|
|
|
});
|
2022-06-23 19:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handlePurgePostShow(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({
|
|
|
|
showPurgeDialog: true,
|
|
|
|
purgeType: PurgeType.Post,
|
|
|
|
showRemoveDialog: false,
|
|
|
|
});
|
2022-06-23 19:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handlePurgeReasonChange(i: PostListing, event: any) {
|
2023-01-04 16:56:24 +00:00
|
|
|
i.setState({ purgeReason: event.target.value });
|
2022-06-23 19:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handlePurgeSubmit(i: PostListing, event: any) {
|
|
|
|
event.preventDefault();
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ purgeLoading: true });
|
|
|
|
if (i.state.purgeType == PurgeType.Person) {
|
|
|
|
i.props.onPurgePerson({
|
|
|
|
person_id: i.postView.creator.id,
|
|
|
|
reason: i.state.purgeReason,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
|
|
|
} else if (i.state.purgeType == PurgeType.Post) {
|
|
|
|
i.props.onPurgePost({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
reason: i.state.purgeReason,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2023-01-04 16:56:24 +00:00
|
|
|
}
|
2022-06-23 19:44:05 +00:00
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
handleModBanReasonChange(i: PostListing, event: any) {
|
2023-01-04 16:56:24 +00:00
|
|
|
i.setState({ banReason: event.target.value });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 17:53:11 +00:00
|
|
|
handleModBanExpireDaysChange(i: PostListing, event: any) {
|
2023-01-04 16:56:24 +00:00
|
|
|
i.setState({ banExpireDays: event.target.value });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
handleModBanFromCommunitySubmit(i: PostListing, event: any) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ banType: BanType.Community });
|
2023-06-14 12:20:40 +00:00
|
|
|
i.handleModBanBothSubmit(i, event);
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
handleModBanSubmit(i: PostListing, event: any) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ banType: BanType.Site });
|
2023-06-14 12:20:40 +00:00
|
|
|
i.handleModBanBothSubmit(i, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanBothSubmit(i: PostListing, event: any) {
|
|
|
|
event.preventDefault();
|
|
|
|
i.setState({ banLoading: true });
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
const ban = !i.props.post_view.creator_banned_from_community;
|
|
|
|
// If its an unban, restore all their data
|
|
|
|
if (ban == false) {
|
|
|
|
i.setState({ removeData: false });
|
|
|
|
}
|
|
|
|
const person_id = i.props.post_view.creator.id;
|
|
|
|
const remove_data = i.state.removeData;
|
|
|
|
const reason = i.state.banReason;
|
|
|
|
const expires = futureDaysToUnixTime(i.state.banExpireDays);
|
|
|
|
|
|
|
|
if (i.state.banType == BanType.Community) {
|
|
|
|
const community_id = i.postView.community.id;
|
|
|
|
i.props.onBanPersonFromCommunity({
|
|
|
|
community_id,
|
|
|
|
person_id,
|
|
|
|
ban,
|
|
|
|
remove_data,
|
|
|
|
reason,
|
|
|
|
expires,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
i.props.onBanPerson({
|
|
|
|
person_id,
|
|
|
|
ban,
|
|
|
|
remove_data,
|
|
|
|
reason,
|
|
|
|
expires,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2023-01-04 16:56:24 +00:00
|
|
|
}
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleAddModToCommunity(i: PostListing) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ addModLoading: true });
|
|
|
|
i.props.onAddModToCommunity({
|
|
|
|
community_id: i.postView.community.id,
|
|
|
|
person_id: i.postView.creator.id,
|
|
|
|
added: !i.creatorIsMod_,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleAddAdmin(i: PostListing) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ addAdminLoading: true });
|
|
|
|
i.props.onAddAdmin({
|
|
|
|
person_id: i.postView.creator.id,
|
|
|
|
added: !i.creatorIsAdmin_,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleShowConfirmTransferCommunity(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showConfirmTransferCommunity: true });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleCancelShowConfirmTransferCommunity(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showConfirmTransferCommunity: false });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleTransferCommunity(i: PostListing) {
|
2023-06-14 12:20:40 +00:00
|
|
|
i.setState({ transferLoading: true });
|
|
|
|
i.props.onTransferCommunity({
|
|
|
|
community_id: i.postView.community.id,
|
|
|
|
person_id: i.postView.creator.id,
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleShowConfirmTransferSite(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showConfirmTransferSite: true });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleCancelShowConfirmTransferSite(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showConfirmTransferSite: false });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-09-19 20:29:03 +00:00
|
|
|
handleImageExpandClick(i: PostListing, event: any) {
|
|
|
|
event.preventDefault();
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ imageExpanded: !i.state.imageExpanded });
|
2022-01-12 00:53:23 +00:00
|
|
|
setupTippy();
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleViewSource(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ viewSource: !i.state.viewSource });
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleShowAdvanced(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showAdvanced: !i.state.showAdvanced });
|
2020-09-06 16:15:25 +00:00
|
|
|
setupTippy();
|
|
|
|
}
|
|
|
|
|
2020-09-26 16:18:49 +00:00
|
|
|
handleShowMoreMobile(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({
|
|
|
|
showMoreMobile: !i.state.showMoreMobile,
|
|
|
|
showAdvanced: !i.state.showAdvanced,
|
|
|
|
});
|
2020-09-26 16:18:49 +00:00
|
|
|
setupTippy();
|
|
|
|
}
|
|
|
|
|
2021-03-25 16:44:16 +00:00
|
|
|
handleShowBody(i: PostListing) {
|
2022-09-22 15:03:35 +00:00
|
|
|
i.setState({ showBody: !i.state.showBody });
|
2021-03-25 16:44:16 +00:00
|
|
|
setupTippy();
|
|
|
|
}
|
|
|
|
|
2023-06-14 12:20:40 +00:00
|
|
|
handleUpvote(i: PostListing) {
|
|
|
|
i.setState({ upvoteLoading: true });
|
|
|
|
i.props.onPostVote({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
score: newVote(VoteType.Upvote, i.props.post_view.my_vote),
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
handleDownvote(i: PostListing) {
|
|
|
|
i.setState({ downvoteLoading: true });
|
|
|
|
i.props.onPostVote({
|
|
|
|
post_id: i.postView.post.id,
|
|
|
|
score: newVote(VoteType.Downvote, i.props.post_view.my_vote),
|
|
|
|
auth: myAuthRequired(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-06 16:15:25 +00:00
|
|
|
get pointsTippy(): string {
|
2023-06-05 21:31:12 +00:00
|
|
|
const points = i18n.t("number_of_points", {
|
2023-06-14 12:20:40 +00:00
|
|
|
count: Number(this.postView.counts.score),
|
|
|
|
formattedCount: Number(this.postView.counts.score),
|
2020-09-06 16:15:25 +00:00
|
|
|
});
|
|
|
|
|
2023-06-05 21:31:12 +00:00
|
|
|
const upvotes = i18n.t("number_of_upvotes", {
|
2023-06-14 12:20:40 +00:00
|
|
|
count: Number(this.postView.counts.upvotes),
|
|
|
|
formattedCount: Number(this.postView.counts.upvotes),
|
2020-09-06 16:15:25 +00:00
|
|
|
});
|
|
|
|
|
2023-06-05 21:31:12 +00:00
|
|
|
const downvotes = i18n.t("number_of_downvotes", {
|
2023-06-14 12:20:40 +00:00
|
|
|
count: Number(this.postView.counts.downvotes),
|
|
|
|
formattedCount: Number(this.postView.counts.downvotes),
|
2020-09-06 16:15:25 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return `${points} • ${upvotes} • ${downvotes}`;
|
|
|
|
}
|
2022-06-21 21:42:29 +00:00
|
|
|
|
|
|
|
get canModOnSelf_(): boolean {
|
|
|
|
return canMod(
|
2023-06-14 12:20:40 +00:00
|
|
|
this.postView.creator.id,
|
2022-06-21 21:42:29 +00:00
|
|
|
this.props.moderators,
|
|
|
|
this.props.admins,
|
|
|
|
undefined,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get canMod_(): boolean {
|
|
|
|
return canMod(
|
2023-06-14 12:20:40 +00:00
|
|
|
this.postView.creator.id,
|
2022-06-21 21:42:29 +00:00
|
|
|
this.props.moderators,
|
2023-01-04 16:56:24 +00:00
|
|
|
this.props.admins
|
2022-06-21 21:42:29 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get canAdmin_(): boolean {
|
2023-06-14 12:20:40 +00:00
|
|
|
return canAdmin(this.postView.creator.id, this.props.admins);
|
2022-06-21 21:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get creatorIsMod_(): boolean {
|
2023-06-14 12:20:40 +00:00
|
|
|
return isMod(this.postView.creator.id, this.props.moderators);
|
2022-06-21 21:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get creatorIsAdmin_(): boolean {
|
2023-06-14 12:20:40 +00:00
|
|
|
return isAdmin(this.postView.creator.id, this.props.admins);
|
2022-06-21 21:42:29 +00:00
|
|
|
}
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|