Feature/user community block (#362)

* Extracting user settings and profile page.

- Auto-collapsing dropdown and navbar on link clicks.
- Fixes #180

* Adding User and Community blocking. Fixes #295

- Added a new settings page.
- Switched to myUserInfo.
- Removing GetFollowedCommunities endpoint

* Fixing blocks
This commit is contained in:
Dessalines 2021-08-19 22:56:18 -04:00 committed by GitHub
parent 2356b0d62f
commit b27d982a7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 2217 additions and 1603 deletions

View file

@ -5,6 +5,7 @@ import {
AddModToCommunity,
BanFromCommunity,
BanPerson,
BlockPerson,
CommentView,
CommunityModeratorView,
CreateCommentLike,
@ -279,7 +280,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
)}
</button>
)}
{UserService.Instance.localUserView && !this.props.viewOnly && (
{UserService.Instance.myUserInfo && !this.props.viewOnly && (
<>
<button
className={`btn btn-link btn-animate ${
@ -333,15 +334,28 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
) : (
<>
{!this.myComment && (
<button class="btn btn-link btn-animate">
<Link
className="text-muted"
to={`/create_private_message/recipient/${cv.creator.id}`}
title={i18n.t("message").toLowerCase()}
<>
<button class="btn btn-link btn-animate">
<Link
className="text-muted"
to={`/create_private_message/recipient/${cv.creator.id}`}
title={i18n.t("message").toLowerCase()}
>
<Icon icon="mail" />
</Link>
</button>
<button
class="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleBlockUserClick
)}
data-tippy-content={i18n.t("block_user")}
aria-label={i18n.t("block_user")}
>
<Icon icon="mail" />
</Link>
</button>
<Icon icon="slash" />
</button>
</>
)}
<button
class="btn btn-link btn-animate text-muted"
@ -829,7 +843,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
get myComment(): boolean {
return (
this.props.node.comment_view.creator.id ==
UserService.Instance.localUserView?.person.id
UserService.Instance.myUserInfo?.local_user_view.person.id
);
}
@ -864,7 +878,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
.concat(this.props.moderators.map(m => m.moderator.id));
return canMod(
UserService.Instance.localUserView,
UserService.Instance.myUserInfo,
adminsThenMods,
this.props.node.comment_view.creator.id
);
@ -877,7 +891,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
return (
this.props.admins &&
canMod(
UserService.Instance.localUserView,
UserService.Instance.myUserInfo,
this.props.admins.map(a => a.person.id),
this.props.node.comment_view.creator.id
)
@ -887,10 +901,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
get amCommunityCreator(): boolean {
return (
this.props.moderators &&
UserService.Instance.localUserView &&
UserService.Instance.myUserInfo &&
this.props.node.comment_view.creator.id !=
UserService.Instance.localUserView.person.id &&
UserService.Instance.localUserView.person.id ==
UserService.Instance.myUserInfo.local_user_view.person.id &&
UserService.Instance.myUserInfo.local_user_view.person.id ==
this.props.moderators[0].moderator.id
);
}
@ -898,10 +912,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
get amSiteCreator(): boolean {
return (
this.props.admins &&
UserService.Instance.localUserView &&
UserService.Instance.myUserInfo &&
this.props.node.comment_view.creator.id !=
UserService.Instance.localUserView.person.id &&
UserService.Instance.localUserView.person.id ==
UserService.Instance.myUserInfo.local_user_view.person.id &&
UserService.Instance.myUserInfo.local_user_view.person.id ==
this.props.admins[0].person.id
);
}
@ -925,6 +939,15 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
i.setState(i.state);
}
handleBlockUserClick(i: CommentNode) {
let blockUserForm: BlockPerson = {
person_id: i.props.node.comment_view.creator.id,
block: true,
auth: authField(),
};
WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm));
}
handleDeleteClick(i: CommentNode) {
let comment = i.props.node.comment_view.comment;
let deleteForm: DeleteComment = {