Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
hide leave section if you aren't in the room instead of disabling
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Oct 11, 2021
1 parent 8cb4454 commit c4d4229
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ export default class GeneralRoomSettingsTab extends React.Component<IProps, ISta
</>;
}

let leaveSection;
if (room.getMyMembership() === "join") {
leaveSection = <>
<span className='mx_SettingsTab_subheading'>{ _t("Leave room") }</span>
<div className='mx_SettingsTab_section'>
<AccessibleButton kind='danger' onClick={this.onLeaveClick}>
{ _t('Leave room') }
</AccessibleButton>
</div>
</>;
}

return (
<div className="mx_SettingsTab mx_GeneralRoomSettingsTab">
<div className="mx_SettingsTab_heading">{ _t("General") }</div>
Expand All @@ -109,17 +121,7 @@ export default class GeneralRoomSettingsTab extends React.Component<IProps, ISta
<div className="mx_SettingsTab_heading">{ _t("Other") }</div>
{ flairSection }
{ urlPreviewSettings }

<span className='mx_SettingsTab_subheading'>{ _t("Leave room") }</span>
<div className='mx_SettingsTab_section'>
<AccessibleButton
kind='danger'
onClick={this.onLeaveClick}
disabled={room.getMyMembership() !== "join"}
>
{ _t('Leave room') }
</AccessibleButton>
</div>
{ leaveSection }
</div>
);
}
Expand Down

0 comments on commit c4d4229

Please sign in to comment.