move the logic to the parent so that the section hiding works

pull/21833/head
Michael Telatynski 2021-10-06 17:08:32 +01:00
parent 52d0b0133c
commit ab98549fff
1 changed files with 3 additions and 8 deletions

View File

@ -535,8 +535,6 @@ interface IBaseProps {
const RoomKickButton: React.FC<IBaseProps> = ({ member, startUpdating, stopUpdating }) => {
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
if (member.membership !== "invite" && member.membership !== "join") return null;
@ -661,9 +659,6 @@ const RedactMessagesButton: React.FC<IBaseProps> = ({ member }) => {
const BanToggleButton: React.FC<IBaseProps> = ({ member, startUpdating, stopUpdating }) => {
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 { finished } = Modal.createTrackedDialog(
'Confirm User Action Dialog',
@ -822,7 +817,7 @@ const RoomAdminToolsContainer: React.FC<IBaseRoomProps> = ({
const isMe = me.userId === member.userId;
const canAffectUser = member.powerLevel < me.powerLevel || isMe;
if (canAffectUser && me.powerLevel >= kickPowerLevel) {
if (!isMe && canAffectUser && me.powerLevel >= kickPowerLevel) {
kickButton = <RoomKickButton member={member} startUpdating={startUpdating} stopUpdating={stopUpdating} />;
}
if (me.powerLevel >= redactPowerLevel && (!SpaceStore.spacesEnabled || !room.isSpaceRoom())) {
@ -830,10 +825,10 @@ const RoomAdminToolsContainer: React.FC<IBaseRoomProps> = ({
<RedactMessagesButton member={member} startUpdating={startUpdating} stopUpdating={stopUpdating} />
);
}
if (canAffectUser && me.powerLevel >= banPowerLevel) {
if (!isMe && canAffectUser && me.powerLevel >= banPowerLevel) {
banButton = <BanToggleButton member={member} startUpdating={startUpdating} stopUpdating={stopUpdating} />;
}
if (canAffectUser && me.powerLevel >= editPowerLevel && !room.isSpaceRoom()) {
if (!isMe && canAffectUser && me.powerLevel >= editPowerLevel && !room.isSpaceRoom()) {
muteButton = (
<MuteToggleButton
member={member}