2020-09-06 16:15:25 +00:00
|
|
|
import { Component, linkEvent } from 'inferno';
|
|
|
|
import { Link } from 'inferno-router';
|
|
|
|
import {
|
2020-12-24 01:58:27 +00:00
|
|
|
CommunityView,
|
|
|
|
CommunityModeratorView,
|
|
|
|
FollowCommunity,
|
|
|
|
DeleteCommunity,
|
|
|
|
RemoveCommunity,
|
|
|
|
UserViewSafe,
|
|
|
|
AddModToCommunity,
|
2020-09-08 18:44:55 +00:00
|
|
|
Category,
|
2020-09-06 16:15:25 +00:00
|
|
|
} from 'lemmy-js-client';
|
|
|
|
import { WebSocketService, UserService } from '../services';
|
2020-12-24 22:05:57 +00:00
|
|
|
import { mdToHtml, getUnixTime, wsClient, authField } from '../utils';
|
2020-09-06 16:15:25 +00:00
|
|
|
import { CommunityForm } from './community-form';
|
|
|
|
import { UserListing } from './user-listing';
|
|
|
|
import { CommunityLink } from './community-link';
|
|
|
|
import { BannerIconHeader } from './banner-icon-header';
|
|
|
|
import { i18n } from '../i18next';
|
|
|
|
|
|
|
|
interface SidebarProps {
|
2020-12-24 01:58:27 +00:00
|
|
|
community_view: CommunityView;
|
2020-09-08 18:44:55 +00:00
|
|
|
categories: Category[];
|
2020-12-24 01:58:27 +00:00
|
|
|
moderators: CommunityModeratorView[];
|
|
|
|
admins: UserViewSafe[];
|
2020-09-06 16:15:25 +00:00
|
|
|
online: number;
|
|
|
|
enableNsfw: boolean;
|
|
|
|
showIcon?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface SidebarState {
|
|
|
|
showEdit: boolean;
|
|
|
|
showRemoveDialog: boolean;
|
|
|
|
removeReason: string;
|
|
|
|
removeExpires: string;
|
|
|
|
showConfirmLeaveModTeam: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Sidebar extends Component<SidebarProps, SidebarState> {
|
|
|
|
private emptyState: SidebarState = {
|
|
|
|
showEdit: false,
|
|
|
|
showRemoveDialog: false,
|
|
|
|
removeReason: null,
|
|
|
|
removeExpires: null,
|
|
|
|
showConfirmLeaveModTeam: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
this.state = this.emptyState;
|
|
|
|
this.handleEditCommunity = this.handleEditCommunity.bind(this);
|
|
|
|
this.handleEditCancel = this.handleEditCancel.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{!this.state.showEdit ? (
|
|
|
|
this.sidebar()
|
|
|
|
) : (
|
|
|
|
<CommunityForm
|
2020-09-08 18:44:55 +00:00
|
|
|
categories={this.props.categories}
|
2020-12-24 01:58:27 +00:00
|
|
|
community_view={this.props.community_view}
|
2020-09-06 16:15:25 +00:00
|
|
|
onEdit={this.handleEditCommunity}
|
|
|
|
onCancel={this.handleEditCancel}
|
|
|
|
enableNsfw={this.props.enableNsfw}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
sidebar() {
|
|
|
|
return (
|
|
|
|
<div>
|
2020-09-23 23:01:45 +00:00
|
|
|
<div class="card border-secondary mb-3">
|
|
|
|
<div class="card-body">
|
2020-09-06 16:15:25 +00:00
|
|
|
{this.communityTitle()}
|
|
|
|
{this.adminButtons()}
|
2020-09-23 23:01:45 +00:00
|
|
|
{this.subscribe()}
|
|
|
|
{this.createPost()}
|
2020-09-06 16:15:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-09-23 23:01:45 +00:00
|
|
|
<div class="card border-secondary mb-3">
|
2020-09-06 16:15:25 +00:00
|
|
|
<div class="card-body">
|
|
|
|
{this.description()}
|
|
|
|
{this.badges()}
|
|
|
|
{this.mods()}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
communityTitle() {
|
2020-12-24 01:58:27 +00:00
|
|
|
let community = this.props.community_view.community;
|
|
|
|
let subscribed = this.props.community_view.subscribed;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h5 className="mb-0">
|
|
|
|
{this.props.showIcon && (
|
|
|
|
<BannerIconHeader icon={community.icon} banner={community.banner} />
|
|
|
|
)}
|
2020-09-23 23:01:45 +00:00
|
|
|
<span class="mr-2">{community.title}</span>
|
2020-12-24 01:58:27 +00:00
|
|
|
{subscribed && (
|
2020-09-23 23:01:45 +00:00
|
|
|
<a
|
|
|
|
class="btn btn-secondary btn-sm mr-2"
|
|
|
|
href="#"
|
|
|
|
onClick={linkEvent(community.id, this.handleUnsubscribe)}
|
|
|
|
>
|
|
|
|
<svg class="text-success mr-1 icon icon-inline">
|
|
|
|
<use xlinkHref="#icon-check"></use>
|
|
|
|
</svg>
|
|
|
|
{i18n.t('joined')}
|
|
|
|
</a>
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
{community.removed && (
|
2020-09-23 23:01:45 +00:00
|
|
|
<small className="mr-2 text-muted font-italic">
|
2020-09-06 16:15:25 +00:00
|
|
|
{i18n.t('removed')}
|
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{community.deleted && (
|
2020-09-23 23:01:45 +00:00
|
|
|
<small className="mr-2 text-muted font-italic">
|
2020-09-06 16:15:25 +00:00
|
|
|
{i18n.t('deleted')}
|
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
{community.nsfw && (
|
2020-09-23 23:01:45 +00:00
|
|
|
<small className="mr-2 text-muted font-italic">
|
2020-09-06 16:15:25 +00:00
|
|
|
{i18n.t('nsfw')}
|
|
|
|
</small>
|
|
|
|
)}
|
|
|
|
</h5>
|
|
|
|
<CommunityLink
|
|
|
|
community={community}
|
|
|
|
realLink
|
|
|
|
useApubName
|
|
|
|
muted
|
|
|
|
hideAvatar
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
badges() {
|
2020-12-24 01:58:27 +00:00
|
|
|
let community_view = this.props.community_view;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<ul class="my-1 list-inline">
|
2020-09-23 23:01:45 +00:00
|
|
|
<li className="list-inline-item badge badge-secondary">
|
2020-09-06 16:15:25 +00:00
|
|
|
{i18n.t('number_online', { count: this.props.online })}
|
|
|
|
</li>
|
2020-09-23 23:01:45 +00:00
|
|
|
<li className="list-inline-item badge badge-secondary">
|
2020-09-06 16:15:25 +00:00
|
|
|
{i18n.t('number_of_subscribers', {
|
2020-12-24 01:58:27 +00:00
|
|
|
count: community_view.counts.subscribers,
|
2020-09-06 16:15:25 +00:00
|
|
|
})}
|
|
|
|
</li>
|
2020-09-23 23:01:45 +00:00
|
|
|
<li className="list-inline-item badge badge-secondary">
|
2020-09-06 16:15:25 +00:00
|
|
|
{i18n.t('number_of_posts', {
|
2020-12-24 01:58:27 +00:00
|
|
|
count: community_view.counts.posts,
|
2020-09-06 16:15:25 +00:00
|
|
|
})}
|
|
|
|
</li>
|
2020-09-23 23:01:45 +00:00
|
|
|
<li className="list-inline-item badge badge-secondary">
|
2020-09-06 16:15:25 +00:00
|
|
|
{i18n.t('number_of_comments', {
|
2020-12-24 01:58:27 +00:00
|
|
|
count: community_view.counts.comments,
|
2020-09-06 16:15:25 +00:00
|
|
|
})}
|
|
|
|
</li>
|
|
|
|
<li className="list-inline-item">
|
2020-09-23 23:01:45 +00:00
|
|
|
<Link className="badge badge-secondary" to="/communities">
|
2020-12-24 01:58:27 +00:00
|
|
|
{community_view.category.name}
|
2020-09-06 16:15:25 +00:00
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
<li className="list-inline-item">
|
|
|
|
<Link
|
2020-09-23 23:01:45 +00:00
|
|
|
className="badge badge-secondary"
|
2020-12-24 01:58:27 +00:00
|
|
|
to={`/modlog/community/${this.props.community_view.community.id}`}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
|
|
|
{i18n.t('modlog')}
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
mods() {
|
|
|
|
return (
|
|
|
|
<ul class="list-inline small">
|
|
|
|
<li class="list-inline-item">{i18n.t('mods')}: </li>
|
|
|
|
{this.props.moderators.map(mod => (
|
|
|
|
<li class="list-inline-item">
|
2020-12-24 01:58:27 +00:00
|
|
|
<UserListing user={mod.moderator} />
|
2020-09-06 16:15:25 +00:00
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:01:45 +00:00
|
|
|
createPost() {
|
2020-12-24 01:58:27 +00:00
|
|
|
let community_view = this.props.community_view;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2020-12-24 01:58:27 +00:00
|
|
|
community_view.subscribed && (
|
2020-09-06 16:15:25 +00:00
|
|
|
<Link
|
2020-09-23 23:01:45 +00:00
|
|
|
className={`btn btn-secondary btn-block mb-2 ${
|
2020-12-24 01:58:27 +00:00
|
|
|
community_view.community.deleted || community_view.community.removed
|
|
|
|
? 'no-click'
|
|
|
|
: ''
|
2020-09-06 16:15:25 +00:00
|
|
|
}`}
|
2020-12-24 01:58:27 +00:00
|
|
|
to={`/create_post?community_id=${community_view.community.id}`}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
|
|
|
{i18n.t('create_a_post')}
|
|
|
|
</Link>
|
2020-09-23 23:01:45 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
subscribe() {
|
2020-12-24 01:58:27 +00:00
|
|
|
let community_view = this.props.community_view;
|
2020-09-23 23:01:45 +00:00
|
|
|
return (
|
|
|
|
<div class="mb-2">
|
2020-12-24 01:58:27 +00:00
|
|
|
{!community_view.subscribed && (
|
2020-09-06 16:15:25 +00:00
|
|
|
<a
|
2020-09-23 23:01:45 +00:00
|
|
|
class="btn btn-secondary btn-block"
|
2020-09-06 16:15:25 +00:00
|
|
|
href="#"
|
2020-12-24 01:58:27 +00:00
|
|
|
onClick={linkEvent(
|
|
|
|
community_view.community.id,
|
|
|
|
this.handleSubscribe
|
|
|
|
)}
|
2020-09-06 16:15:25 +00:00
|
|
|
>
|
|
|
|
{i18n.t('subscribe')}
|
|
|
|
</a>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
description() {
|
2020-12-24 01:58:27 +00:00
|
|
|
let description = this.props.community_view.community.description;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2020-12-24 01:58:27 +00:00
|
|
|
description && (
|
2020-09-06 16:15:25 +00:00
|
|
|
<div
|
|
|
|
className="md-div"
|
2020-12-24 01:58:27 +00:00
|
|
|
dangerouslySetInnerHTML={mdToHtml(description)}
|
2020-09-06 16:15:25 +00:00
|
|
|
/>
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
adminButtons() {
|
2020-12-24 01:58:27 +00:00
|
|
|
let community_view = this.props.community_view;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<ul class="list-inline mb-1 text-muted font-weight-bold">
|
|
|
|
{this.canMod && (
|
|
|
|
<>
|
|
|
|
<li className="list-inline-item-action">
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleEditClick)}
|
|
|
|
data-tippy-content={i18n.t('edit')}
|
|
|
|
>
|
|
|
|
<svg class="icon icon-inline">
|
|
|
|
<use xlinkHref="#icon-edit"></use>
|
|
|
|
</svg>
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
{!this.amCreator &&
|
|
|
|
(!this.state.showConfirmLeaveModTeam ? (
|
|
|
|
<li className="list-inline-item-action">
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleShowConfirmLeaveModTeamClick
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{i18n.t('leave_mod_team')}
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<li className="list-inline-item-action">
|
|
|
|
{i18n.t('are_you_sure')}
|
|
|
|
</li>
|
|
|
|
<li className="list-inline-item-action">
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleLeaveModTeamClick)}
|
|
|
|
>
|
|
|
|
{i18n.t('yes')}
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
<li className="list-inline-item-action">
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(
|
|
|
|
this,
|
|
|
|
this.handleCancelLeaveModTeamClick
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{i18n.t('no')}
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
</>
|
|
|
|
))}
|
|
|
|
{this.amCreator && (
|
|
|
|
<li className="list-inline-item-action">
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleDeleteClick)}
|
|
|
|
data-tippy-content={
|
2020-12-24 01:58:27 +00:00
|
|
|
!community_view.community.deleted
|
|
|
|
? i18n.t('delete')
|
|
|
|
: i18n.t('restore')
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
>
|
|
|
|
<svg
|
|
|
|
class={`icon icon-inline ${
|
2020-12-24 01:58:27 +00:00
|
|
|
community_view.community.deleted && 'text-danger'
|
2020-09-06 16:15:25 +00:00
|
|
|
}`}
|
|
|
|
>
|
|
|
|
<use xlinkHref="#icon-trash"></use>
|
|
|
|
</svg>
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{this.canAdmin && (
|
|
|
|
<li className="list-inline-item">
|
2020-12-24 01:58:27 +00:00
|
|
|
{!this.props.community_view.community.removed ? (
|
2020-09-06 16:15:25 +00:00
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleModRemoveShow)}
|
|
|
|
>
|
|
|
|
{i18n.t('remove')}
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<span
|
|
|
|
class="pointer"
|
|
|
|
onClick={linkEvent(this, this.handleModRemoveSubmit)}
|
|
|
|
>
|
|
|
|
{i18n.t('restore')}
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</li>
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
{this.state.showRemoveDialog && (
|
|
|
|
<form onSubmit={linkEvent(this, this.handleModRemoveSubmit)}>
|
|
|
|
<div class="form-group row">
|
|
|
|
<label class="col-form-label" htmlFor="remove-reason">
|
|
|
|
{i18n.t('reason')}
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="remove-reason"
|
|
|
|
class="form-control mr-2"
|
|
|
|
placeholder={i18n.t('optional')}
|
|
|
|
value={this.state.removeReason}
|
|
|
|
onInput={linkEvent(this, this.handleModRemoveReasonChange)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{/* TODO hold off on expires for now */}
|
|
|
|
{/* <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.removeExpires} onInput={linkEvent(this, this.handleModRemoveExpiresChange)} /> */}
|
|
|
|
{/* </div> */}
|
|
|
|
<div class="form-group row">
|
|
|
|
<button type="submit" class="btn btn-secondary">
|
|
|
|
{i18n.t('remove_community')}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleEditClick(i: Sidebar) {
|
|
|
|
i.state.showEdit = true;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleEditCommunity() {
|
|
|
|
this.state.showEdit = false;
|
|
|
|
this.setState(this.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleEditCancel() {
|
|
|
|
this.state.showEdit = false;
|
|
|
|
this.setState(this.state);
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:01:45 +00:00
|
|
|
handleDeleteClick(i: Sidebar, event: any) {
|
2020-09-06 16:15:25 +00:00
|
|
|
event.preventDefault();
|
2020-12-24 01:58:27 +00:00
|
|
|
let deleteForm: DeleteCommunity = {
|
2021-01-18 22:42:41 +00:00
|
|
|
community_id: i.props.community_view.community.id,
|
2020-12-24 01:58:27 +00:00
|
|
|
deleted: !i.props.community_view.community.deleted,
|
2020-12-24 22:05:57 +00:00
|
|
|
auth: authField(),
|
2020-09-06 16:15:25 +00:00
|
|
|
};
|
2020-12-24 22:05:57 +00:00
|
|
|
WebSocketService.Instance.send(wsClient.deleteCommunity(deleteForm));
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handleShowConfirmLeaveModTeamClick(i: Sidebar) {
|
|
|
|
i.state.showConfirmLeaveModTeam = true;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleLeaveModTeamClick(i: Sidebar) {
|
2020-12-24 01:58:27 +00:00
|
|
|
let form: AddModToCommunity = {
|
2020-09-06 16:15:25 +00:00
|
|
|
user_id: UserService.Instance.user.id,
|
2020-12-24 01:58:27 +00:00
|
|
|
community_id: i.props.community_view.community.id,
|
2020-09-06 16:15:25 +00:00
|
|
|
added: false,
|
2020-12-24 22:05:57 +00:00
|
|
|
auth: authField(),
|
2020-09-06 16:15:25 +00:00
|
|
|
};
|
2020-12-24 22:05:57 +00:00
|
|
|
WebSocketService.Instance.send(wsClient.addModToCommunity(form));
|
2020-09-06 16:15:25 +00:00
|
|
|
i.state.showConfirmLeaveModTeam = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleCancelLeaveModTeamClick(i: Sidebar) {
|
|
|
|
i.state.showConfirmLeaveModTeam = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:01:45 +00:00
|
|
|
handleUnsubscribe(communityId: number, event: any) {
|
2020-09-06 16:15:25 +00:00
|
|
|
event.preventDefault();
|
2020-12-24 01:58:27 +00:00
|
|
|
let form: FollowCommunity = {
|
2020-09-06 16:15:25 +00:00
|
|
|
community_id: communityId,
|
|
|
|
follow: false,
|
2020-12-24 22:05:57 +00:00
|
|
|
auth: authField(),
|
2020-09-06 16:15:25 +00:00
|
|
|
};
|
2020-12-24 22:05:57 +00:00
|
|
|
WebSocketService.Instance.send(wsClient.followCommunity(form));
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
2020-09-23 23:01:45 +00:00
|
|
|
handleSubscribe(communityId: number, event: any) {
|
2020-09-06 16:15:25 +00:00
|
|
|
event.preventDefault();
|
2020-12-24 01:58:27 +00:00
|
|
|
let form: FollowCommunity = {
|
2020-09-06 16:15:25 +00:00
|
|
|
community_id: communityId,
|
|
|
|
follow: true,
|
2020-12-24 22:05:57 +00:00
|
|
|
auth: authField(),
|
2020-09-06 16:15:25 +00:00
|
|
|
};
|
2020-12-24 22:05:57 +00:00
|
|
|
WebSocketService.Instance.send(wsClient.followCommunity(form));
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private get amCreator(): boolean {
|
2020-12-24 01:58:27 +00:00
|
|
|
return this.props.community_view.creator.id == UserService.Instance.user.id;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get canMod(): boolean {
|
|
|
|
return (
|
|
|
|
UserService.Instance.user &&
|
|
|
|
this.props.moderators
|
2020-12-24 01:58:27 +00:00
|
|
|
.map(m => m.moderator.id)
|
2020-09-06 16:15:25 +00:00
|
|
|
.includes(UserService.Instance.user.id)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
get canAdmin(): boolean {
|
|
|
|
return (
|
|
|
|
UserService.Instance.user &&
|
2020-12-24 01:58:27 +00:00
|
|
|
this.props.admins
|
|
|
|
.map(a => a.user.id)
|
|
|
|
.includes(UserService.Instance.user.id)
|
2020-09-06 16:15:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveShow(i: Sidebar) {
|
|
|
|
i.state.showRemoveDialog = true;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveReasonChange(i: Sidebar, event: any) {
|
|
|
|
i.state.removeReason = event.target.value;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModRemoveExpiresChange(i: Sidebar, event: any) {
|
|
|
|
console.log(event.target.value);
|
|
|
|
i.state.removeExpires = event.target.value;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:01:45 +00:00
|
|
|
handleModRemoveSubmit(i: Sidebar, event: any) {
|
2020-09-06 16:15:25 +00:00
|
|
|
event.preventDefault();
|
2020-12-24 01:58:27 +00:00
|
|
|
let removeForm: RemoveCommunity = {
|
2021-01-18 22:42:41 +00:00
|
|
|
community_id: i.props.community_view.community.id,
|
2020-12-24 01:58:27 +00:00
|
|
|
removed: !i.props.community_view.community.removed,
|
2020-09-06 16:15:25 +00:00
|
|
|
reason: i.state.removeReason,
|
|
|
|
expires: getUnixTime(i.state.removeExpires),
|
2020-12-24 22:05:57 +00:00
|
|
|
auth: authField(),
|
2020-09-06 16:15:25 +00:00
|
|
|
};
|
2020-12-24 22:05:57 +00:00
|
|
|
WebSocketService.Instance.send(wsClient.removeCommunity(removeForm));
|
2020-09-06 16:15:25 +00:00
|
|
|
|
|
|
|
i.state.showRemoveDialog = false;
|
|
|
|
i.setState(i.state);
|
|
|
|
}
|
|
|
|
}
|