From 6f004d219c4d4cefd1e68f5ca4827f2e6cb5c7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 19 Sep 2021 09:59:53 +0200 Subject: [PATCH] Convert UrlPreviewSettings to TS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- ...viewSettings.js => UrlPreviewSettings.tsx} | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) rename src/components/views/room_settings/{UrlPreviewSettings.js => UrlPreviewSettings.tsx} (88%) diff --git a/src/components/views/room_settings/UrlPreviewSettings.js b/src/components/views/room_settings/UrlPreviewSettings.tsx similarity index 88% rename from src/components/views/room_settings/UrlPreviewSettings.js rename to src/components/views/room_settings/UrlPreviewSettings.tsx index 0ff3b051d6..bb639b691a 100644 --- a/src/components/views/room_settings/UrlPreviewSettings.js +++ b/src/components/views/room_settings/UrlPreviewSettings.tsx @@ -18,8 +18,6 @@ limitations under the License. */ import React from 'react'; -import PropTypes from 'prop-types'; -import * as sdk from "../../../index"; import { _t, _td } from '../../../languageHandler'; import SettingsStore from "../../../settings/SettingsStore"; import dis from "../../../dispatcher/dispatcher"; @@ -27,21 +25,22 @@ import { MatrixClientPeg } from "../../../MatrixClientPeg"; import { Action } from "../../../dispatcher/actions"; import { SettingLevel } from "../../../settings/SettingLevel"; import { replaceableComponent } from "../../../utils/replaceableComponent"; +import { Room } from "matrix-js-sdk/src/models/room"; +import SettingsFlag from "../elements/SettingsFlag"; + +interface IProps { + room: Room; +} @replaceableComponent("views.room_settings.UrlPreviewSettings") -export default class UrlPreviewSettings extends React.Component { - static propTypes = { - room: PropTypes.object, - }; - - _onClickUserSettings = (e) => { +export default class UrlPreviewSettings extends React.Component { + private onClickUserSettings = (e: React.MouseEvent): void => { e.preventDefault(); e.stopPropagation(); dis.fire(Action.ViewUserSettings); }; - render() { - const SettingsFlag = sdk.getComponent("elements.SettingsFlag"); + public render(): JSX.Element { const roomId = this.props.room.roomId; const isEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId); @@ -54,18 +53,18 @@ export default class UrlPreviewSettings extends React.Component { if (accountEnabled) { previewsForAccount = ( _t("You have enabled URL previews by default.", {}, { - 'a': (sub)=>{ sub }, + 'a': (sub)=>{ sub }, }) ); } else { previewsForAccount = ( _t("You have disabled URL previews by default.", {}, { - 'a': (sub)=>{ sub }, + 'a': (sub)=>{ sub }, }) ); } - if (SettingsStore.canSetValue("urlPreviewsEnabled", roomId, "room")) { + if (SettingsStore.canSetValue("urlPreviewsEnabled", roomId, SettingLevel.ROOM)) { previewsForRoom = (