Hide kick & ban options in UserInfo when looking at own profile

This commit is contained in:
Michael Telatynski 2021-10-06 14:46:39 +01:00
parent 1d5a1c7a82
commit 52d0b0133c

View file

@ -535,6 +535,8 @@ interface IBaseProps {
const RoomKickButton: React.FC<IBaseProps> = ({ member, startUpdating, stopUpdating }) => { const RoomKickButton: React.FC<IBaseProps> = ({ member, startUpdating, stopUpdating }) => {
const cli = useContext(MatrixClientContext); const cli = useContext(MatrixClientContext);
// don't render this button on our own profile, we don't want to kick ourselves
if (member.userId === cli.getUserId()) return null;
// check if user can be kicked/disinvited // check if user can be kicked/disinvited
if (member.membership !== "invite" && member.membership !== "join") return null; if (member.membership !== "invite" && member.membership !== "join") return null;
@ -659,6 +661,9 @@ const RedactMessagesButton: React.FC<IBaseProps> = ({ member }) => {
const BanToggleButton: React.FC<IBaseProps> = ({ member, startUpdating, stopUpdating }) => { const BanToggleButton: React.FC<IBaseProps> = ({ member, startUpdating, stopUpdating }) => {
const cli = useContext(MatrixClientContext); const cli = useContext(MatrixClientContext);
// don't render this button on our own profile, we don't want to ban ourselves and can't unban ourselves anyhow
if (member.userId === cli.getUserId()) return null;
const onBanOrUnban = async () => { const onBanOrUnban = async () => {
const { finished } = Modal.createTrackedDialog( const { finished } = Modal.createTrackedDialog(
'Confirm User Action Dialog', 'Confirm User Action Dialog',