From ce8d07fa7205d1dd808482c17b9b910f97c8ef26 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 1 Sep 2023 13:03:53 +0100 Subject: [PATCH] Only display RoomKnocksBar when feature flag is enabled (#11513) --- src/components/views/rooms/LegacyRoomHeader.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/LegacyRoomHeader.tsx b/src/components/views/rooms/LegacyRoomHeader.tsx index 8bee8f3fad3..8f20acab71c 100644 --- a/src/components/views/rooms/LegacyRoomHeader.tsx +++ b/src/components/views/rooms/LegacyRoomHeader.tsx @@ -480,6 +480,7 @@ export interface IProps { interface IState { contextMenuPosition?: DOMRect; rightPanelOpen: boolean; + featureAskToJoin: boolean; } /** @@ -496,6 +497,7 @@ export default class RoomHeader extends React.Component { public static contextType = RoomContext; public context!: React.ContextType; private readonly client = this.props.room.client; + private readonly featureAskToJoinWatcher: string; public constructor(props: IProps, context: IState) { super(props, context); @@ -503,7 +505,15 @@ export default class RoomHeader extends React.Component { notiStore.on(NotificationStateEvents.Update, this.onNotificationUpdate); this.state = { rightPanelOpen: RightPanelStore.instance.isOpen, + featureAskToJoin: SettingsStore.getValue("feature_ask_to_join"), }; + this.featureAskToJoinWatcher = SettingsStore.watchSetting( + "feature_ask_to_join", + null, + (_settingName, _roomId, _atLevel, _newValAtLevel, featureAskToJoin) => { + this.setState({ featureAskToJoin }); + }, + ); } public componentDidMount(): void { @@ -516,6 +526,7 @@ export default class RoomHeader extends React.Component { const notiStore = RoomNotificationStateStore.instance.getRoomState(this.props.room); notiStore.removeListener(NotificationStateEvents.Update, this.onNotificationUpdate); RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate); + SettingsStore.unwatchSetting(this.featureAskToJoinWatcher); } private onRightPanelStoreUpdate = (): void => { @@ -821,7 +832,7 @@ export default class RoomHeader extends React.Component { {!isVideoRoom && } - + {this.state.featureAskToJoin && } ); }