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

Hide leave section button if user isn't in the room e.g peeking #6920

Merged
merged 2 commits into from
Oct 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import React, { ContextType } from 'react';
import { _t } from "../../../../../languageHandler";
import RoomProfileSettings from "../../../room_settings/RoomProfileSettings";
import AccessibleButton from "../../../elements/AccessibleButton";
Expand All @@ -38,9 +38,10 @@ interface IState {
@replaceableComponent("views.settings.tabs.room.GeneralRoomSettingsTab")
export default class GeneralRoomSettingsTab extends React.Component<IProps, IState> {
public static contextType = MatrixClientContext;
context: ContextType<typeof MatrixClientContext>;

constructor(props: IProps) {
super(props);
constructor(props: IProps, context: ContextType<typeof MatrixClientContext>) {
super(props, context);

this.state = {
isRoomPublished: false, // loaded async
Expand Down Expand Up @@ -111,7 +112,11 @@ export default class GeneralRoomSettingsTab extends React.Component<IProps, ISta

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