From 8cb4454ea3a218c7734d2479b0f5d0bf07e00c6b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 8 Oct 2021 13:43:06 +0100 Subject: [PATCH 1/2] Disable leave room button if user isn't in the room e.g peeking --- .../settings/tabs/room/GeneralRoomSettingsTab.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx b/src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx index 790e2999f5..37ac358660 100644 --- a/src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx +++ b/src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx @@ -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"; @@ -38,9 +38,10 @@ interface IState { @replaceableComponent("views.settings.tabs.room.GeneralRoomSettingsTab") export default class GeneralRoomSettingsTab extends React.Component { public static contextType = MatrixClientContext; + context: ContextType; - constructor(props: IProps) { - super(props); + constructor(props: IProps, context: ContextType) { + super(props, context); this.state = { isRoomPublished: false, // loaded async @@ -111,7 +112,11 @@ export default class GeneralRoomSettingsTab extends React.Component{ _t("Leave room") }
- + { _t('Leave room') }
From c4d4229340475e343d52806f3becef421b7f37c7 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 11 Oct 2021 13:50:34 +0100 Subject: [PATCH 2/2] hide leave section if you aren't in the room instead of disabling --- .../tabs/room/GeneralRoomSettingsTab.tsx | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx b/src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx index 37ac358660..1cfe023ba9 100644 --- a/src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx +++ b/src/components/views/settings/tabs/room/GeneralRoomSettingsTab.tsx @@ -90,6 +90,18 @@ export default class GeneralRoomSettingsTab extends React.Component; } + let leaveSection; + if (room.getMyMembership() === "join") { + leaveSection = <> + { _t("Leave room") } +
+ + { _t('Leave room') } + +
+ ; + } + return (
{ _t("General") }
@@ -109,17 +121,7 @@ export default class GeneralRoomSettingsTab extends React.Component{ _t("Other") }
{ flairSection } { urlPreviewSettings } - - { _t("Leave room") } -
- - { _t('Leave room') } - -
+ { leaveSection } ); }