import {
AddAdminResponse,
BanPersonResponse,
+ BlockPerson,
BlockPersonResponse,
CommentResponse,
GetPersonDetails,
sort: SortType;
page: number;
loading: boolean;
+ personBlocked: boolean;
siteRes: GetSiteResponse;
}
view: Profile.getViewFromProps(this.props.match.view),
sort: Profile.getSortTypeFromProps(this.props.match.sort),
page: Profile.getPageFromProps(this.props.match.page),
+ personBlocked: false,
siteRes: this.isoData.site_res,
};
}
setupTippy();
+ this.setPersonBlock();
}
fetchUserData() {
);
}
+ setPersonBlock() {
+ this.state.personBlocked = UserService.Instance.myUserInfo.person_blocks
+ .map(a => a.target.id)
+ .includes(this.state.personRes?.person_view.person.id);
+ }
+
static getViewFromProps(view: string): PersonDetailsView {
return view ? PersonDetailsView[view] : PersonDetailsView.Overview;
}
</div>
);
}
+ handleBlockPerson(personId: number) {
+ if (personId != 0) {
+ let blockUserForm: BlockPerson = {
+ person_id: personId,
+ block: true,
+ auth: authField(),
+ };
+ WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm));
+ }
+ }
+ handleUnblockPerson(recipientId: number) {
+ let blockUserForm: BlockPerson = {
+ person_id: recipientId,
+ block: false,
+ auth: authField(),
+ };
+ WebSocketService.Instance.send(wsClient.blockPerson(blockUserForm));
+ }
userInfo() {
let pv = this.state.personRes?.person_view;
{i18n.t("send_secure_message")}
</a>
<Link
- className={"d-flex align-self-start btn btn-secondary"}
+ className={"d-flex align-self-start btn btn-secondary mr-2"}
to={`/create_private_message/recipient/${pv.person.id}`}
>
{i18n.t("send_message")}
</Link>
+ {this.state.personBlocked ? (
+ <button
+ className={"d-flex align-self-start btn btn-secondary"}
+ onClick={linkEvent(
+ pv.person.id,
+ this.handleUnblockPerson
+ )}
+ >
+ {i18n.t("unblock_user")}
+ </button>
+ ) : (
+ <button
+ className={"d-flex align-self-start btn btn-secondary"}
+ onClick={linkEvent(pv.person.id, this.handleBlockPerson)}
+ >
+ {i18n.t("block_user")}
+ </button>
+ )}
</>
)}
</div>
this.state.personRes = data;
console.log(data);
this.state.loading = false;
+ this.setPersonBlock();
this.setState(this.state);
restoreScrollPosition(this.context);
} else if (op == UserOperation.AddAdmin) {
} else if (op == UserOperation.BlockPerson) {
let data = wsJsonToRes<BlockPersonResponse>(msg).data;
updatePersonBlock(data);
+ this.setPersonBlock();
+ this.setState(this.state);
}
}
}