From e88227dac8023e86352b74ec2a57061a05cdefac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 21 Sep 2021 13:19:13 +0200 Subject: [PATCH] Convert LabsUserSettingsTab to TS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- ...SettingsTab.js => LabsUserSettingsTab.tsx} | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) rename src/components/views/settings/tabs/user/{LabsUserSettingsTab.js => LabsUserSettingsTab.tsx} (90%) diff --git a/src/components/views/settings/tabs/user/LabsUserSettingsTab.js b/src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx similarity index 90% rename from src/components/views/settings/tabs/user/LabsUserSettingsTab.js rename to src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx index 943eb874ed..60461a114c 100644 --- a/src/components/views/settings/tabs/user/LabsUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx @@ -16,7 +16,6 @@ limitations under the License. import React from 'react'; import { _t } from "../../../../../languageHandler"; -import PropTypes from "prop-types"; import SettingsStore from "../../../../../settings/SettingsStore"; import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch"; import { SettingLevel } from "../../../../../settings/SettingLevel"; @@ -26,28 +25,32 @@ import BetaCard from "../../../beta/BetaCard"; import SettingsFlag from '../../../elements/SettingsFlag'; import { MatrixClientPeg } from '../../../../../MatrixClientPeg'; -export class LabsSettingToggle extends React.Component { - static propTypes = { - featureId: PropTypes.string.isRequired, - }; +interface ILabsSettingToggleProps { + featureId: string; +} - _onChange = async (checked) => { +export class LabsSettingToggle extends React.Component { + private onChange = async (checked: boolean): Promise => { await SettingsStore.setValue(this.props.featureId, null, SettingLevel.DEVICE, checked); this.forceUpdate(); }; - render() { + public render(): JSX.Element { const label = SettingsStore.getDisplayName(this.props.featureId); const value = SettingsStore.getValue(this.props.featureId); const canChange = SettingsStore.canSetValue(this.props.featureId, null, SettingLevel.DEVICE); - return ; + return ; } } +interface IState { + showHiddenReadReceipts: boolean; +} + @replaceableComponent("views.settings.tabs.user.LabsUserSettingsTab") -export default class LabsUserSettingsTab extends React.Component { - constructor() { - super(); +export default class LabsUserSettingsTab extends React.Component<{}, IState> { + constructor(props: {}) { + super(props); MatrixClientPeg.get().doesServerSupportUnstableFeature("org.matrix.msc2285").then((showHiddenReadReceipts) => { this.setState({ showHiddenReadReceipts }); @@ -58,7 +61,7 @@ export default class LabsUserSettingsTab extends React.Component { }; } - render() { + public render(): JSX.Element { const features = SettingsStore.getFeatureSettingNames(); const [labs, betas] = features.reduce((arr, f) => { arr[SettingsStore.getBetaInfo(f) ? 1 : 0].push(f);