2019-04-03 06:49:32 +00:00
|
|
|
import { Component, linkEvent } from 'inferno';
|
|
|
|
import { Link } from 'inferno-router';
|
|
|
|
import { WebSocketService, UserService } from '../services';
|
2019-10-19 00:20:27 +00:00
|
|
|
import {
|
|
|
|
Post,
|
|
|
|
CreatePostLikeForm,
|
|
|
|
PostForm as PostFormI,
|
|
|
|
SavePostForm,
|
|
|
|
CommunityUser,
|
|
|
|
UserView,
|
|
|
|
BanType,
|
|
|
|
BanFromCommunityForm,
|
|
|
|
BanUserForm,
|
|
|
|
AddModToCommunityForm,
|
|
|
|
AddAdminForm,
|
|
|
|
TransferSiteForm,
|
|
|
|
TransferCommunityForm,
|
|
|
|
} from '../interfaces';
|
2019-04-03 06:49:32 +00:00
|
|
|
import { MomentTime } from './moment-time';
|
2019-04-03 20:59:37 +00:00
|
|
|
import { PostForm } from './post-form';
|
2019-10-19 00:20:27 +00:00
|
|
|
import {
|
|
|
|
mdToHtml,
|
|
|
|
canMod,
|
|
|
|
isMod,
|
|
|
|
isImage,
|
|
|
|
isVideo,
|
|
|
|
getUnixTime,
|
2019-12-29 20:39:48 +00:00
|
|
|
pictshareAvatarThumbnail,
|
2020-01-02 21:55:54 +00:00
|
|
|
showAvatars,
|
2020-01-03 19:13:22 +00:00
|
|
|
imageThumbnailer,
|
2019-10-19 00:20:27 +00:00
|
|
|
} from '../utils';
|
2019-08-10 00:14:43 +00:00
|
|
|
import { i18n } from '../i18next';
|
|
|
|
import { T } from 'inferno-i18next';
|
2019-04-03 06:49:32 +00:00
|
|
|
|
|
|
|
interface PostListingState {
|
2019-04-03 20:59:37 +00:00
|
|
|
showEdit: boolean;
|
2019-04-15 23:12:06 +00:00
|
|
|
showRemoveDialog: boolean;
|
|
|
|
removeReason: string;
|
2019-09-06 00:18:48 +00:00
|
|
|
showBanDialog: boolean;
|
|
|
|
banReason: string;
|
|
|
|
banExpires: string;
|
|
|
|
banType: BanType;
|
|
|
|
showConfirmTransferSite: boolean;
|
|
|
|
showConfirmTransferCommunity: boolean;
|
2019-04-24 16:28:20 +00:00
|
|
|
imageExpanded: boolean;
|
2019-09-08 18:00:08 +00:00
|
|
|
viewSource: boolean;
|
2020-01-14 03:57:32 +00:00
|
|
|
my_vote: number;
|
|
|
|
score: number;
|
2019-04-03 06:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface PostListingProps {
|
|
|
|
post: Post;
|
|
|
|
showCommunity?: boolean;
|
|
|
|
showBody?: boolean;
|
2019-04-08 05:19:02 +00:00
|
|
|
viewOnly?: boolean;
|
2019-04-20 07:24:59 +00:00
|
|
|
moderators?: Array<CommunityUser>;
|
|
|
|
admins?: Array<UserView>;
|
2019-04-03 06:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class PostListing extends Component<PostListingProps, PostListingState> {
|
|
|
|
private emptyState: PostListingState = {
|
2019-04-05 00:01:10 +00:00
|
|
|
showEdit: false,
|
2019-04-15 23:12:06 +00:00
|
|
|
showRemoveDialog: false,
|
|
|
|
removeReason: null,
|
2019-09-06 00:18:48 +00:00
|
|
|
showBanDialog: false,
|
|
|
|
banReason: null,
|
|
|
|
banExpires: null,
|
|
|
|
banType: BanType.Community,
|
|
|
|
showConfirmTransferSite: false,
|
|
|
|
showConfirmTransferCommunity: false,
|
|
|
|
imageExpanded: false,
|
2019-09-08 18:00:08 +00:00
|
|
|
viewSource: false,
|
2020-01-14 03:57:32 +00:00
|
|
|
my_vote: this.props.post.my_vote,
|
|
|
|
score: this.props.post.score,
|
2019-10-19 00:20:27 +00:00
|
|
|
};
|
2019-04-03 06:49:32 +00:00
|
|
|
|
2019-04-08 05:19:02 +00:00
|
|
|
constructor(props: any, context: any) {
|
2019-04-03 06:49:32 +00:00
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.state = this.emptyState;
|
|
|
|
this.handlePostLike = this.handlePostLike.bind(this);
|
|
|
|
this.handlePostDisLike = this.handlePostDisLike.bind(this);
|
2019-04-03 20:59:37 +00:00
|
|
|
this.handleEditPost = this.handleEditPost.bind(this);
|
2019-04-05 02:08:21 +00:00
|
|
|
this.handleEditCancel = this.handleEditCancel.bind(this);
|
2019-04-03 06:49:32 +00:00
|
|
|
}
|
|
|
|
|
2019-04-04 22:29:14 +00:00
|
|
|
render() {
|
|
|
|
return (
|
2019-08-24 06:58:26 +00:00
|
|
|
<div class="row">
|
2019-10-19 00:20:27 +00:00
|
|
|
{!this.state.showEdit ? (
|
|
|
|
this.listing()
|
|
|
|
) : (
|
2019-09-01 04:10:48 +00:00
|
|
|
<div class="col-12">
|
2019-10-19 00:20:27 +00:00
|
|
|
<PostForm
|
|
|
|
post={this.props.post}
|
|
|
|
onEdit={this.handleEditPost}
|
|
|
|
onCancel={this.handleEditCancel}
|
|
|
|
/>
|
2019-09-01 04:10:48 +00:00
|
|
|
</div>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-04-04 22:29:14 +00:00
|
|
|
</div>
|
2019-10-19 00:20:27 +00:00
|
|
|
);
|
2019-04-03 20:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
listing() {
|
2019-04-03 06:49:32 +00:00
|
|
|
let post = this.props.post;
|
|
|
|
return (
|
2019-08-24 06:58:26 +00:00
|
|
|
<div class="listing col-12">
|
2019-10-19 00:20:27 +00:00
|
|
|
<div
|
|
|
|
className={`vote-bar mr-2 float-left small text-center ${this.props
|
|
|
|
.viewOnly && 'no-click'}`}
|
|
|
|
>
|
|
|
|
<button
|
2020-01-14 15:38:45 +00:00
|
|
|
disabled={!UserService.Instance.user}
|
2019-10-19 00:20:27 +00:00
|
|
|
className={`btn p-0 ${
|
2020-01-14 03:57:32 +00:00
|
|
|
this.state.my_vote == 1 ? 'text-info' : 'text-muted'
|
2019-10-19 00:20:27 +00:00
|
|
|
}`}
|
|
|
|
onClick={linkEvent(this, this.handlePostLike)}
|
|
|
|
>
|
|
|
|
<svg class="icon upvote">
|
|
|
|
<use xlinkHref="#icon-arrow-up"></use>
|
|
|
|
</svg>
|
2019-08-19 22:32:32 +00:00
|
|
|
</button>
|
2020-01-14 03:57:32 +00:00
|
|
|
<div class={`font-weight-bold text-muted`}>{this.state.score}</div>
|
2019-12-11 20:21:47 +00:00
|
|
|
{WebSocketService.Instance.site.enable_downvotes && (
|
|
|
|
<button
|
2020-01-14 15:38:45 +00:00
|
|
|
disabled={!UserService.Instance.user}
|
2019-12-11 20:21:47 +00:00
|
|
|
className={`btn p-0 ${
|
2020-01-14 03:57:32 +00:00
|
|
|
this.state.my_vote == -1 ? 'text-danger' : 'text-muted'
|
2019-12-11 20:21:47 +00:00
|
|
|
}`}
|
|
|
|
onClick={linkEvent(this, this.handlePostDisLike)}
|
|
|
|
>
|
|
|
|
<svg class="icon downvote">
|
|
|
|
<use xlinkHref="#icon-arrow-down"></use>
|
|
|
|
</svg>
|
|
|
|
</button>
|
|
|
|
)}
|
2019-04-03 06:49:32 +00:00
|
|
|
</div>
|
2019-11-23 00:26:16 +00:00
|
|
|
{post.url && isImage(post.url) && !post.nsfw && !post.community_nsfw && (
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
title={i18n.t('expand_here')}
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleImageExpandClick)}
|
|
|
|
>
|
|
|
|
<img
|
|
|
|
class="mx-2 mt-1 float-left img-fluid thumbnail rounded"
|
2020-01-03 19:13:22 +00:00
|
|
|
src={imageThumbnailer(post.url)}
|
2019-10-19 00:20:27 +00:00
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{post.url && isVideo(post.url) && (
|
|
|
|
<video
|
|
|
|
playsinline
|
|
|
|
muted
|
|
|
|
loop
|
|
|
|
controls
|
|
|
|
class="mx-2 mt-1 float-left"
|
|
|
|
height="100"
|
|
|
|
width="150"
|
|
|
|
>
|
2019-09-08 03:42:01 +00:00
|
|
|
<source src={post.url} type="video/mp4" />
|
|
|
|
</video>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-04-24 15:26:49 +00:00
|
|
|
<div className="ml-4">
|
2019-08-18 04:41:55 +00:00
|
|
|
<div className="post-title">
|
2019-08-19 21:13:15 +00:00
|
|
|
<h5 className="mb-0 d-inline">
|
2019-10-19 00:20:27 +00:00
|
|
|
{post.url ? (
|
|
|
|
<a
|
|
|
|
className="text-body"
|
|
|
|
href={post.url}
|
|
|
|
target="_blank"
|
|
|
|
title={post.url}
|
|
|
|
>
|
|
|
|
{post.name}
|
|
|
|
</a>
|
|
|
|
) : (
|
|
|
|
<Link
|
|
|
|
className="text-body"
|
|
|
|
to={`/post/${post.id}`}
|
|
|
|
title={i18n.t('comments')}
|
|
|
|
>
|
|
|
|
{post.name}
|
|
|
|
</Link>
|
|
|
|
)}
|
2019-08-19 21:13:15 +00:00
|
|
|
</h5>
|
2019-10-19 00:20:27 +00:00
|
|
|
{post.url && (
|
2019-04-25 03:57:07 +00:00
|
|
|
<small>
|
2019-10-19 00:20:27 +00:00
|
|
|
<a
|
|
|
|
className="ml-2 text-muted font-italic"
|
|
|
|
href={post.url}
|
|
|
|
target="_blank"
|
|
|
|
title={post.url}
|
|
|
|
>
|
|
|
|
{new URL(post.url).hostname}
|
|
|
|
</a>
|
2019-04-25 03:57:07 +00:00
|
|
|
</small>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{post.url && isImage(post.url) && (
|
2019-04-25 03:57:07 +00:00
|
|
|
<>
|
2019-10-19 00:20:27 +00:00
|
|
|
{!this.state.imageExpanded ? (
|
|
|
|
<span
|
|
|
|
class="text-monospace pointer ml-2 text-muted small"
|
|
|
|
title={i18n.t('expand_here')}
|
|
|
|
onClick={linkEvent(this, this.handleImageExpandClick)}
|
|
|
|
>
|
|
|
|
[+]
|
|
|
|
</span>
|
|
|
|
) : (
|
2019-04-25 03:57:07 +00:00
|
|
|
<span>
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="text-monospace pointer ml-2 text-muted small"
|
|
|
|
onClick={linkEvent(this, this.handleImageExpandClick)}
|
|
|
|
>
|
|
|
|
[-]
|
|
|
|
</span>
|
2019-04-25 03:57:07 +00:00
|
|
|
<div>
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleImageExpandClick)}
|
|
|
|
>
|
|
|
|
<img class="img-fluid" src={post.url} />
|
|
|
|
</span>
|
2019-04-25 03:57:07 +00:00
|
|
|
</div>
|
|
|
|
</span>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-04-25 03:57:07 +00:00
|
|
|
</>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{post.removed && (
|
|
|
|
<small className="ml-2 text-muted font-italic">
|
|
|
|
<T i18nKey="removed">#</T>
|
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{post.deleted && (
|
|
|
|
<small className="ml-2 text-muted font-italic">
|
|
|
|
<T i18nKey="deleted">#</T>
|
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{post.locked && (
|
|
|
|
<small className="ml-2 text-muted font-italic">
|
|
|
|
<T i18nKey="locked">#</T>
|
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{post.stickied && (
|
|
|
|
<small className="ml-2 text-muted font-italic">
|
|
|
|
<T i18nKey="stickied">#</T>
|
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{post.nsfw && (
|
|
|
|
<small className="ml-2 text-muted font-italic">
|
|
|
|
<T i18nKey="nsfw">#</T>
|
|
|
|
</small>
|
|
|
|
)}
|
2019-04-25 03:57:07 +00:00
|
|
|
</div>
|
2019-04-03 06:49:32 +00:00
|
|
|
</div>
|
2019-08-18 04:47:25 +00:00
|
|
|
<div className="details ml-4">
|
2019-04-03 06:49:32 +00:00
|
|
|
<ul class="list-inline mb-0 text-muted small">
|
|
|
|
<li className="list-inline-item">
|
2019-08-23 22:55:48 +00:00
|
|
|
<span>{i18n.t('by')} </span>
|
2019-10-19 00:20:27 +00:00
|
|
|
<Link className="text-info" to={`/u/${post.creator_name}`}>
|
2020-01-02 21:55:54 +00:00
|
|
|
{post.creator_avatar && showAvatars() && (
|
2019-12-29 20:39:48 +00:00
|
|
|
<img
|
|
|
|
height="32"
|
|
|
|
width="32"
|
|
|
|
src={pictshareAvatarThumbnail(post.creator_avatar)}
|
|
|
|
class="rounded-circle mr-1"
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<span>{post.creator_name}</span>
|
2019-10-19 00:20:27 +00:00
|
|
|
</Link>
|
|
|
|
{this.isMod && (
|
|
|
|
<span className="mx-1 badge badge-light">
|
|
|
|
<T i18nKey="mod">#</T>
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{this.isAdmin && (
|
|
|
|
<span className="mx-1 badge badge-light">
|
|
|
|
<T i18nKey="admin">#</T>
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{(post.banned_from_community || post.banned) && (
|
|
|
|
<span className="mx-1 badge badge-danger">
|
|
|
|
<T i18nKey="banned">#</T>
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{this.props.showCommunity && (
|
2019-04-03 06:49:32 +00:00
|
|
|
<span>
|
2019-08-23 22:55:48 +00:00
|
|
|
<span> {i18n.t('to')} </span>
|
2019-10-19 00:20:27 +00:00
|
|
|
<Link to={`/c/${post.community_name}`}>
|
|
|
|
{post.community_name}
|
|
|
|
</Link>
|
2019-04-03 06:49:32 +00:00
|
|
|
</span>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-04-03 06:49:32 +00:00
|
|
|
</li>
|
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span>
|
|
|
|
<MomentTime data={post} />
|
|
|
|
</span>
|
2019-04-03 06:49:32 +00:00
|
|
|
</li>
|
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span>
|
|
|
|
(<span className="text-info">+{post.upvotes}</span>
|
2019-04-03 06:49:32 +00:00
|
|
|
<span> | </span>
|
|
|
|
<span className="text-danger">-{post.downvotes}</span>
|
|
|
|
<span>) </span>
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<Link className="text-muted" to={`/post/${post.id}`}>
|
|
|
|
<T
|
|
|
|
i18nKey="number_of_comments"
|
|
|
|
interpolation={{ count: post.number_of_comments }}
|
|
|
|
>
|
|
|
|
#
|
|
|
|
</T>
|
|
|
|
</Link>
|
2019-04-03 06:49:32 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
2019-10-19 00:20:27 +00:00
|
|
|
<ul class="list-inline mb-1 text-muted small font-weight-bold">
|
|
|
|
{UserService.Instance.user && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<>
|
2019-10-19 00:20:27 +00:00
|
|
|
{this.props.showBody && (
|
2019-10-14 00:36:35 +00:00
|
|
|
<>
|
|
|
|
<li className="list-inline-item mr-2">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleSavePostClick)}
|
|
|
|
>
|
|
|
|
{post.saved ? i18n.t('unsave') : i18n.t('save')}
|
|
|
|
</span>
|
2019-10-14 00:36:35 +00:00
|
|
|
</li>
|
|
|
|
<li className="list-inline-item mr-2">
|
2019-10-19 00:20:27 +00:00
|
|
|
<Link
|
|
|
|
className="text-muted"
|
|
|
|
to={`/create_post${this.crossPostParams}`}
|
|
|
|
>
|
|
|
|
<T i18nKey="cross_post">#</T>
|
|
|
|
</Link>
|
2019-10-14 00:36:35 +00:00
|
|
|
</li>
|
|
|
|
</>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{this.myPost && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<>
|
2019-09-06 00:18:48 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleEditClick)}
|
|
|
|
>
|
|
|
|
<T i18nKey="edit">#</T>
|
|
|
|
</span>
|
2019-09-06 00:18:48 +00:00
|
|
|
</li>
|
2019-09-08 18:00:08 +00:00
|
|
|
<li className="list-inline-item mr-2">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleDeleteClick)}
|
|
|
|
>
|
2019-09-08 18:00:08 +00:00
|
|
|
{!post.deleted ? i18n.t('delete') : i18n.t('restore')}
|
|
|
|
</span>
|
2019-09-06 00:18:48 +00:00
|
|
|
</li>
|
2019-09-08 18:00:08 +00:00
|
|
|
</>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{this.canModOnSelf && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<>
|
2019-09-06 00:18:48 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleModLock)}
|
|
|
|
>
|
|
|
|
{post.locked ? i18n.t('unlock') : i18n.t('lock')}
|
|
|
|
</span>
|
2019-09-06 00:18:48 +00:00
|
|
|
</li>
|
2019-09-09 06:14:13 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleModSticky)}
|
|
|
|
>
|
|
|
|
{post.stickied ? i18n.t('unsticky') : i18n.t('sticky')}
|
|
|
|
</span>
|
2019-09-09 06:14:13 +00:00
|
|
|
</li>
|
2019-09-08 18:00:08 +00:00
|
|
|
</>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
{/* Mods can ban from community, and appoint as mods to community */}
|
2019-10-19 00:20:27 +00:00
|
|
|
{(this.canMod || this.canAdmin) && (
|
2019-10-14 00:36:35 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
{!post.removed ? (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleModRemoveShow)}
|
|
|
|
>
|
|
|
|
<T i18nKey="remove">#</T>
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleModRemoveSubmit)}
|
|
|
|
>
|
|
|
|
<T i18nKey="restore">#</T>
|
|
|
|
</span>
|
|
|
|
)}
|
2019-10-14 00:36:35 +00:00
|
|
|
</li>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{this.canMod && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<>
|
2019-10-19 00:20:27 +00:00
|
|
|
{!this.isMod && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
{!post.banned_from_community ? (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleModBanFromCommunityShow
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<T i18nKey="ban">#</T>
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleModBanFromCommunitySubmit
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<T i18nKey="unban">#</T>
|
|
|
|
</span>
|
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
</li>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{!post.banned_from_community && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleAddModToCommunity
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{this.isMod
|
|
|
|
? i18n.t('remove_as_mod')
|
|
|
|
: i18n.t('appoint_as_mod')}
|
|
|
|
</span>
|
2019-09-08 18:00:08 +00:00
|
|
|
</li>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
</>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
{/* Community creators and admins can transfer community to another mod */}
|
2019-10-19 00:20:27 +00:00
|
|
|
{(this.amCommunityCreator || this.canAdmin) && this.isMod && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
{!this.state.showConfirmTransferCommunity ? (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleShowConfirmTransferCommunity
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<T i18nKey="transfer_community">#</T>
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<span class="d-inline-block mr-1">
|
|
|
|
<T i18nKey="are_you_sure">#</T>
|
|
|
|
</span>
|
|
|
|
<span
|
|
|
|
class="pointer d-inline-block mr-1"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleTransferCommunity
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<T i18nKey="yes">#</T>
|
|
|
|
</span>
|
|
|
|
<span
|
|
|
|
class="pointer d-inline-block"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleCancelShowConfirmTransferCommunity
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<T i18nKey="no">#</T>
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
</li>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
{/* Admins can ban from all, and appoint other admins */}
|
2019-10-19 00:20:27 +00:00
|
|
|
{this.canAdmin && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<>
|
2019-10-19 00:20:27 +00:00
|
|
|
{!this.isAdmin && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
{!post.banned ? (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleModBanShow)}
|
|
|
|
>
|
|
|
|
<T i18nKey="ban_from_site">#</T>
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleModBanSubmit)}
|
|
|
|
>
|
|
|
|
<T i18nKey="unban_from_site">#</T>
|
|
|
|
</span>
|
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
</li>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{!post.banned && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleAddAdmin)}
|
|
|
|
>
|
|
|
|
{this.isAdmin
|
|
|
|
? i18n.t('remove_as_admin')
|
|
|
|
: i18n.t('appoint_as_admin')}
|
|
|
|
</span>
|
2019-09-08 18:00:08 +00:00
|
|
|
</li>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
</>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
{/* Site Creator can transfer to another admin */}
|
2019-10-19 00:20:27 +00:00
|
|
|
{this.amSiteCreator && this.isAdmin && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
{!this.state.showConfirmTransferSite ? (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleShowConfirmTransferSite
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<T i18nKey="transfer_site">#</T>
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<span class="d-inline-block mr-1">
|
|
|
|
<T i18nKey="are_you_sure">#</T>
|
|
|
|
</span>
|
|
|
|
<span
|
|
|
|
class="pointer d-inline-block mr-1"
|
|
|
|
onClick={linkEvent(this, this.handleTransferSite)}
|
|
|
|
>
|
|
|
|
<T i18nKey="yes">#</T>
|
|
|
|
</span>
|
|
|
|
<span
|
|
|
|
class="pointer d-inline-block"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleCancelShowConfirmTransferSite
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<T i18nKey="no">#</T>
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
</li>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
</>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{this.props.showBody && post.body && (
|
2019-09-08 18:00:08 +00:00
|
|
|
<li className="list-inline-item">
|
2019-10-19 00:20:27 +00:00
|
|
|
<span
|
|
|
|
className="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleViewSource)}
|
|
|
|
>
|
|
|
|
<T i18nKey="view_source">#</T>
|
|
|
|
</span>
|
2019-09-08 18:00:08 +00:00
|
|
|
</li>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
2019-09-08 18:00:08 +00:00
|
|
|
</ul>
|
2019-10-19 00:20:27 +00:00
|
|
|
{this.state.showRemoveDialog && (
|
|
|
|
<form
|
|
|
|
class="form-inline"
|
|
|
|
onSubmit={linkEvent(this, this.handleModRemoveSubmit)}
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="form-control mr-2"
|
|
|
|
placeholder={i18n.t('reason')}
|
|
|
|
value={this.state.removeReason}
|
|
|
|
onInput={linkEvent(this, this.handleModRemoveReasonChange)}
|
|
|
|
/>
|
|
|
|
<button type="submit" class="btn btn-secondary">
|
|
|
|
<T i18nKey="remove_post">#</T>
|
|
|
|
</button>
|
2019-04-15 23:12:06 +00:00
|
|
|
</form>
|
2019-10-19 00:20:27 +00:00
|
|
|
)}
|
|
|
|
{this.state.showBanDialog && (
|
2019-09-06 00:18:48 +00:00
|
|
|
<form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
|
|
|
|
<div class="form-group row">
|
2019-10-19 00:20:27 +00:00
|
|
|
<label class="col-form-label">
|
|
|
|
<T i18nKey="reason">#</T>
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="form-control mr-2"
|
|
|
|
placeholder={i18n.t('reason')}
|
|
|
|
value={this.state.banReason}
|
|
|
|
onInput={linkEvent(this, this.handleModBanReasonChange)}
|
|
|
|
/>
|
2019-09-06 00:18:48 +00:00
|
|
|
</div>
|
|
|
|
{/* TODO hold off on expires until later */}
|
|
|
|
{/* <div class="form-group row"> */}
|
2019-10-19 00:20:27 +00:00
|
|
|
{/* <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> */}
|
|
|
|
<div class="form-group row">
|
|
|
|
<button type="submit" class="btn btn-secondary">
|
|
|
|
{i18n.t('ban')} {post.creator_name}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
)}
|
|
|
|
{this.props.showBody && post.body && (
|
|
|
|
<>
|
|
|
|
{this.state.viewSource ? (
|
|
|
|
<pre>{post.body}</pre>
|
|
|
|
) : (
|
|
|
|
<div
|
|
|
|
className="md-div"
|
|
|
|
dangerouslySetInnerHTML={mdToHtml(post.body)}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
2019-04-03 06:49:32 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-10-19 00:20:27 +00:00
|
|
|
);
|
2019-04-03 06:49:32 +00:00
|
|
|
}
|
|
|
|
|
2019-04-03 20:59:37 +00:00
|
|
|
private get myPost(): boolean {
|
2019-10-19 00:20:27 +00:00
|
|
|
return (
|
|
|
|
UserService.Instance.user &&
|
|
|
|
this.props.post.creator_id == UserService.Instance.user.id
|
|
|
|
);
|
2019-04-03 20:59:37 +00:00
|
|
|
}
|
2019-04-03 06:49:32 +00:00
|
|
|
|
2019-04-21 20:52:55 +00:00
|
|
|
get isMod(): boolean {
|
2019-10-19 00:20:27 +00:00
|
|
|
return (
|
|
|
|
this.props.moderators &&
|
|
|
|
isMod(
|
|
|
|
this.props.moderators.map(m => m.user_id),
|
|
|
|
this.props.post.creator_id
|
|
|
|
)
|
|
|
|
);
|
2019-04-21 20:52:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get isAdmin(): boolean {
|
2019-10-19 00:20:27 +00:00
|
|
|
return (
|
|
|
|
this.props.admins &&
|
2020-01-14 03:57:32 +00:00
|
|
|
isMod(
|
|
|
|
this.props.admins.map(a => a.id),
|
|
|
|
this.props.post.creator_id
|
|
|
|
)
|
2019-10-19 00:20:27 +00:00
|
|
|
);
|
2019-04-21 20:52:55 +00:00
|
|
|
}
|
|
|
|
|
2019-04-20 07:24:59 +00:00
|
|
|
get canMod(): boolean {
|
2019-10-14 00:36:35 +00:00
|
|
|
if (this.props.admins && this.props.moderators) {
|
2019-10-19 00:20:27 +00:00
|
|
|
let adminsThenMods = this.props.admins
|
|
|
|
.map(a => a.id)
|
|
|
|
.concat(this.props.moderators.map(m => m.user_id));
|
|
|
|
|
|
|
|
return canMod(
|
|
|
|
UserService.Instance.user,
|
|
|
|
adminsThenMods,
|
|
|
|
this.props.post.creator_id
|
|
|
|
);
|
|
|
|
} else {
|
2019-10-14 00:36:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-09-09 19:58:04 +00:00
|
|
|
}
|
2019-04-20 07:24:59 +00:00
|
|
|
|
2019-09-09 19:58:04 +00:00
|
|
|
get canModOnSelf(): boolean {
|
2019-10-14 00:36:35 +00:00
|
|
|
if (this.props.admins && this.props.moderators) {
|
2019-10-19 00:20:27 +00:00
|
|
|
let adminsThenMods = this.props.admins
|
|
|
|
.map(a => a.id)
|
|
|
|
.concat(this.props.moderators.map(m => m.user_id));
|
|
|
|
|
|
|
|
return canMod(
|
|
|
|
UserService.Instance.user,
|
|
|
|
adminsThenMods,
|
|
|
|
this.props.post.creator_id,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
} else {
|
2019-10-14 00:36:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-04-20 07:24:59 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 00:18:48 +00:00
|
|
|
get canAdmin(): boolean {
|
2019-10-19 00:20:27 +00:00
|
|
|
return (
|
|
|
|
this.props.admins &&
|
|
|
|
canMod(
|
|
|
|
UserService.Instance.user,
|
|
|
|
this.props.admins.map(a => a.id),
|
|
|
|
this.props.post.creator_id
|
|
|
|
)
|
|
|
|
);
|
2019-09-06 00:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get amCommunityCreator(): boolean {
|
2019-10-19 00:20:27 +00:00
|
|
|
return (
|
|
|
|
this.props.moderators &&
|
|
|
|
UserService.Instance.user &&
|
|
|
|
this.props.post.creator_id != UserService.Instance.user.id &&
|
|
|
|
UserService.Instance.user.id == this.props.moderators[0].user_id
|
|
|
|
);
|
2019-09-06 00:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get amSiteCreator(): boolean {
|
2019-10-19 00:20:27 +00:00
|
|
|
return (
|
|
|
|
this.props.admins &&
|
|
|
|
UserService.Instance.user &&
|
|
|
|
this.props.post.creator_id != UserService.Instance.user.id &&
|
|
|
|
UserService.Instance.user.id == this.props.admins[0].id
|
|
|
|
);
|
2019-09-06 00:18:48 +00:00
|
|
|
}
|
|
|
|
|
2019-04-08 05:19:02 +00:00
|
|
|
handlePostLike(i: PostListing) {
|
2020-01-14 03:57:32 +00:00
|
|
|
this.state.my_vote = i.props.post.my_vote == 1 ? 0 : 1;
|
|
|
|
let add = 1;
|
|
|
|
if (i.props.post.my_vote == 1) {
|
|
|
|
add = -1;
|
|
|
|
} else if (i.props.post.my_vote == -1) {
|
|
|
|
add = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.state.score = i.props.post.score + add;
|
|
|
|
this.setState(this.state);
|
|
|
|
|
2019-04-03 06:49:32 +00:00
|
|
|
let form: CreatePostLikeForm = {
|
|
|
|
post_id: i.props.post.id,
|
2020-01-14 03:57:32 +00:00
|
|
|
score: this.state.my_vote,
|
2019-04-03 06:49:32 +00:00
|
|
|
};
|
|
|
|
WebSocketService.Instance.likePost(form);
|
|
|
|
}
|
|
|
|
|
2019-04-08 05:19:02 +00:00
|
|
|
handlePostDisLike(i: PostListing) {
|
2020-01-14 03:57:32 +00:00
|
|
|
this.state.my_vote = i.props.post.my_vote == -1 ? 0 : -1;
|
|
|
|
let add = -1;
|
|
|
|
if (i.props.post.my_vote == 1) {
|
|
|
|
add = -2;
|
|
|
|
} else if (i.props.post.my_vote == -1) {
|
|
|
|
add = 1;
|
|
|
|
}
|
|
|
|
this.state.score = i.props.post.score + add;
|
|
|
|
this.setState(this.state);
|
|
|
|
|
2019-04-03 06:49:32 +00:00
|
|
|
let form: CreatePostLikeForm = {
|
|
|
|
post_id: i.props.post.id,
|
2020-01-14 03:57:32 +00:00
|
|
|
score: this.state.my_vote,
|
2019-04-03 06:49:32 +00:00
|
|
|
};
|
|
|
|
WebSocketService.Instance.likePost(form);
|
|
|
|
}
|
2019-04-03 20:59:37 +00:00
|
|
|
|
2019-04-08 05:19:02 +00:00
|
|
|
handleEditClick(i: PostListing) {
|
2019-04-03 20:59:37 +00:00
|
|
|
i.state.showEdit = true;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
2019-04-05 02:08:21 +00:00
|
|
|
handleEditCancel() {
|
|
|
|
this.state.showEdit = false;
|
|
|
|
this.setState(this.state);
|
|
|
|
}
|
|
|
|
|
2019-04-04 22:29:14 +00:00
|
|
|
// The actual editing is done in the recieve for post
|
2019-04-08 05:19:02 +00:00
|
|
|
handleEditPost() {
|
2019-04-03 20:59:37 +00:00
|
|
|
this.state.showEdit = false;
|
|
|
|
this.setState(this.state);
|
|
|
|
}
|
|
|
|
|
2019-04-08 05:19:02 +00:00
|
|
|
handleDeleteClick(i: PostListing) {
|
2019-04-03 20:59:37 +00:00
|
|
|
let deleteForm: PostFormI = {
|
2019-04-29 19:14:54 +00:00
|
|
|
body: i.props.post.body,
|
2019-04-03 20:59:37 +00:00
|
|
|
community_id: i.props.post.community_id,
|
2019-04-29 19:14:54 +00:00
|
|
|
name: i.props.post.name,
|
|
|
|
url: i.props.post.url,
|
2019-04-03 20:59:37 +00:00
|
|
|
edit_id: i.props.post.id,
|
2019-04-15 23:12:06 +00:00
|
|
|
creator_id: i.props.post.creator_id,
|
2019-04-29 19:14:54 +00:00
|
|
|
deleted: !i.props.post.deleted,
|
2019-08-14 02:52:43 +00:00
|
|
|
nsfw: i.props.post.nsfw,
|
2019-10-19 00:20:27 +00:00
|
|
|
auth: null,
|
2019-04-03 20:59:37 +00:00
|
|
|
};
|
|
|
|
WebSocketService.Instance.editPost(deleteForm);
|
|
|
|
}
|
2019-04-05 00:01:10 +00:00
|
|
|
|
2019-04-20 04:06:25 +00:00
|
|
|
handleSavePostClick(i: PostListing) {
|
2019-10-19 00:20:27 +00:00
|
|
|
let saved = i.props.post.saved == undefined ? true : !i.props.post.saved;
|
2019-04-20 04:06:25 +00:00
|
|
|
let form: SavePostForm = {
|
|
|
|
post_id: i.props.post.id,
|
2019-10-19 00:20:27 +00:00
|
|
|
save: saved,
|
2019-04-20 04:06:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
WebSocketService.Instance.savePost(form);
|
|
|
|
}
|
|
|
|
|
2019-08-22 23:13:26 +00:00
|
|
|
get crossPostParams(): string {
|
|
|
|
let params = `?name=${this.props.post.name}`;
|
|
|
|
if (this.props.post.url) {
|
|
|
|
params += `&url=${this.props.post.url}`;
|
2019-08-22 18:46:54 +00:00
|
|
|
}
|
2019-08-22 23:13:26 +00:00
|
|
|
if (this.props.post.body) {
|
|
|
|
params += `&body=${this.props.post.body}`;
|
2019-08-22 18:46:54 +00:00
|
|
|
}
|
2019-08-22 23:13:26 +00:00
|
|
|
return params;
|
2019-08-22 18:46:54 +00:00
|
|
|
}
|
|
|
|
|
2019-04-15 23:12:06 +00:00
|
|
|
handleModRemoveShow(i: PostListing) {
|
|
|
|
i.state.showRemoveDialog = true;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveReasonChange(i: PostListing, event: any) {
|
|
|
|
i.state.removeReason = event.target.value;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveSubmit(i: PostListing) {
|
2019-04-16 23:04:23 +00:00
|
|
|
event.preventDefault();
|
2019-04-15 23:12:06 +00:00
|
|
|
let form: PostFormI = {
|
|
|
|
name: i.props.post.name,
|
|
|
|
community_id: i.props.post.community_id,
|
|
|
|
edit_id: i.props.post.id,
|
|
|
|
creator_id: i.props.post.creator_id,
|
|
|
|
removed: !i.props.post.removed,
|
|
|
|
reason: i.state.removeReason,
|
2019-08-14 02:52:43 +00:00
|
|
|
nsfw: i.props.post.nsfw,
|
2019-04-15 23:12:06 +00:00
|
|
|
auth: null,
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.editPost(form);
|
|
|
|
|
|
|
|
i.state.showRemoveDialog = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModLock(i: PostListing) {
|
|
|
|
let form: PostFormI = {
|
|
|
|
name: i.props.post.name,
|
|
|
|
community_id: i.props.post.community_id,
|
|
|
|
edit_id: i.props.post.id,
|
|
|
|
creator_id: i.props.post.creator_id,
|
2019-08-14 02:52:43 +00:00
|
|
|
nsfw: i.props.post.nsfw,
|
2019-04-15 23:12:06 +00:00
|
|
|
locked: !i.props.post.locked,
|
|
|
|
auth: null,
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.editPost(form);
|
|
|
|
}
|
|
|
|
|
2019-09-09 06:14:13 +00:00
|
|
|
handleModSticky(i: PostListing) {
|
|
|
|
let form: PostFormI = {
|
|
|
|
name: i.props.post.name,
|
|
|
|
community_id: i.props.post.community_id,
|
|
|
|
edit_id: i.props.post.id,
|
|
|
|
creator_id: i.props.post.creator_id,
|
|
|
|
nsfw: i.props.post.nsfw,
|
|
|
|
stickied: !i.props.post.stickied,
|
|
|
|
auth: null,
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.editPost(form);
|
|
|
|
}
|
|
|
|
|
2019-09-06 00:18:48 +00:00
|
|
|
handleModBanFromCommunityShow(i: PostListing) {
|
|
|
|
i.state.showBanDialog = true;
|
|
|
|
i.state.banType = BanType.Community;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanShow(i: PostListing) {
|
|
|
|
i.state.showBanDialog = true;
|
|
|
|
i.state.banType = BanType.Site;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanReasonChange(i: PostListing, event: any) {
|
|
|
|
i.state.banReason = event.target.value;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanExpiresChange(i: PostListing, event: any) {
|
|
|
|
i.state.banExpires = event.target.value;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanFromCommunitySubmit(i: PostListing) {
|
|
|
|
i.state.banType = BanType.Community;
|
|
|
|
i.setState(i.state);
|
|
|
|
i.handleModBanBothSubmit(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanSubmit(i: PostListing) {
|
|
|
|
i.state.banType = BanType.Site;
|
|
|
|
i.setState(i.state);
|
|
|
|
i.handleModBanBothSubmit(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModBanBothSubmit(i: PostListing) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
if (i.state.banType == BanType.Community) {
|
|
|
|
let form: BanFromCommunityForm = {
|
|
|
|
user_id: i.props.post.creator_id,
|
|
|
|
community_id: i.props.post.community_id,
|
|
|
|
ban: !i.props.post.banned_from_community,
|
|
|
|
reason: i.state.banReason,
|
|
|
|
expires: getUnixTime(i.state.banExpires),
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.banFromCommunity(form);
|
|
|
|
} else {
|
|
|
|
let form: BanUserForm = {
|
|
|
|
user_id: i.props.post.creator_id,
|
|
|
|
ban: !i.props.post.banned,
|
|
|
|
reason: i.state.banReason,
|
|
|
|
expires: getUnixTime(i.state.banExpires),
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.banUser(form);
|
|
|
|
}
|
|
|
|
|
|
|
|
i.state.showBanDialog = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleAddModToCommunity(i: PostListing) {
|
|
|
|
let form: AddModToCommunityForm = {
|
|
|
|
user_id: i.props.post.creator_id,
|
|
|
|
community_id: i.props.post.community_id,
|
|
|
|
added: !i.isMod,
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.addModToCommunity(form);
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleAddAdmin(i: PostListing) {
|
|
|
|
let form: AddAdminForm = {
|
|
|
|
user_id: i.props.post.creator_id,
|
|
|
|
added: !i.isAdmin,
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.addAdmin(form);
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
2019-10-19 00:20:27 +00:00
|
|
|
handleShowConfirmTransferCommunity(i: PostListing) {
|
2019-09-06 00:18:48 +00:00
|
|
|
i.state.showConfirmTransferCommunity = true;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
2019-10-19 00:20:27 +00:00
|
|
|
handleCancelShowConfirmTransferCommunity(i: PostListing) {
|
2019-09-06 00:18:48 +00:00
|
|
|
i.state.showConfirmTransferCommunity = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleTransferCommunity(i: PostListing) {
|
|
|
|
let form: TransferCommunityForm = {
|
|
|
|
community_id: i.props.post.community_id,
|
|
|
|
user_id: i.props.post.creator_id,
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.transferCommunity(form);
|
|
|
|
i.state.showConfirmTransferCommunity = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
2019-10-19 00:20:27 +00:00
|
|
|
handleShowConfirmTransferSite(i: PostListing) {
|
2019-09-06 00:18:48 +00:00
|
|
|
i.state.showConfirmTransferSite = true;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
2019-10-19 00:20:27 +00:00
|
|
|
handleCancelShowConfirmTransferSite(i: PostListing) {
|
2019-09-06 00:18:48 +00:00
|
|
|
i.state.showConfirmTransferSite = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleTransferSite(i: PostListing) {
|
|
|
|
let form: TransferSiteForm = {
|
|
|
|
user_id: i.props.post.creator_id,
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.transferSite(form);
|
|
|
|
i.state.showConfirmTransferSite = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
2019-04-24 16:28:20 +00:00
|
|
|
handleImageExpandClick(i: PostListing) {
|
|
|
|
i.state.imageExpanded = !i.state.imageExpanded;
|
2019-04-05 00:01:10 +00:00
|
|
|
i.setState(i.state);
|
|
|
|
}
|
2019-09-08 18:00:08 +00:00
|
|
|
|
|
|
|
handleViewSource(i: PostListing) {
|
|
|
|
i.state.viewSource = !i.state.viewSource;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
2019-04-03 06:49:32 +00:00
|
|
|
}
|