From 0ae28d584b28b9b33e15f94aa4d7ec9e3b7b1a25 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Fri, 18 Dec 2020 16:05:57 +0200 Subject: [PATCH] Typing and other PR feedback fixes --- .../structures/EMSElementProAction.tsx | 8 ++--- src/components/structures/UserMenu.tsx | 9 ++---- .../views/dialogs/EMSElementProDialog.tsx | 32 +++++++++---------- .../dialogs/EMSElementProDialogTypes.tsx | 28 ++++++++++++++++ 4 files changed, 50 insertions(+), 27 deletions(-) create mode 100644 src/components/views/dialogs/EMSElementProDialogTypes.tsx diff --git a/src/components/structures/EMSElementProAction.tsx b/src/components/structures/EMSElementProAction.tsx index 84526686cf..9426f12234 100644 --- a/src/components/structures/EMSElementProAction.tsx +++ b/src/components/structures/EMSElementProAction.tsx @@ -16,7 +16,7 @@ limitations under the License. import * as React from "react"; import EMSElementProDialog from "../views/dialogs/EMSElementProDialog"; -import Modal from "../../Modal"; +import Modal, {IHandle} from "../../Modal"; import { IconizedContextMenuOption, IconizedContextMenuOptionList, @@ -28,8 +28,8 @@ interface IProps {} interface IState {} export default class EMSElementProAction extends React.PureComponent { - closingAllowed = false; - modalRef: any; + private closingAllowed = false; + private modalRef: IHandle; private openDialog = () => { this.modalRef = Modal.createTrackedDialog( @@ -52,7 +52,7 @@ export default class EMSElementProAction extends React.PureComponent this.openDialog()} + onClick={this.openDialog} /> ); diff --git a/src/components/structures/UserMenu.tsx b/src/components/structures/UserMenu.tsx index 01ed972a99..aa8c6c91a2 100644 --- a/src/components/structures/UserMenu.tsx +++ b/src/components/structures/UserMenu.tsx @@ -319,12 +319,9 @@ export default class UserMenu extends React.Component { "Upgrade to your own domain", {}, { a: sub => ( - {sub} + + {sub} + ), }, )} diff --git a/src/components/views/dialogs/EMSElementProDialog.tsx b/src/components/views/dialogs/EMSElementProDialog.tsx index caad0ffc20..20f04af6f6 100644 --- a/src/components/views/dialogs/EMSElementProDialog.tsx +++ b/src/components/views/dialogs/EMSElementProDialog.tsx @@ -20,9 +20,10 @@ import EMSElementProConfirmCloseDialog from './EMSElementProConfirmCloseDialog'; import EMSElementProDataConfirmDialog from './EMSElementProDataConfirmDialog'; import Modal from "../../../Modal"; import SdkConfig from "../../../SdkConfig"; -import { _t } from "../../../languageHandler"; -import { MatrixClientPeg } from "../../../MatrixClientPeg"; -import { OwnProfileStore } from "../../../stores/OwnProfileStore"; +import {_t} from "../../../languageHandler"; +import {MatrixClientPeg} from "../../../MatrixClientPeg"; +import {OwnProfileStore} from "../../../stores/OwnProfileStore"; +import {IPostmessage, IPostmessageResponseData, PostmessageAction} from "./EMSElementProDialogTypes"; interface IProps { requestClose(): void; @@ -34,8 +35,8 @@ interface IState { } export default class EMSElementProDialog extends React.PureComponent { - iframeRef; - elementProSetupUrl: string; + private iframeRef: React.RefObject = React.createRef(); + private readonly elementProSetupUrl: string; constructor(props: IProps) { super(props); @@ -45,16 +46,15 @@ export default class EMSElementProDialog extends React.PureComponent { + private messageHandler = (message: IPostmessage) => { if (!this.elementProSetupUrl.startsWith(message.origin)) { return; } switch (message.data.action) { - case 'element_pro_account_details_request': + case PostmessageAction.ElementProAccountDetailsRequest: Modal.createDialog( EMSElementProDataConfirmDialog, { @@ -66,14 +66,14 @@ export default class EMSElementProDialog extends React.PureComponent { - this.iframeRef.contentWindow.postMessage( - message, - this.elementProSetupUrl, - ) + private sendMessage = (message: IPostmessageResponseData) => { + this.iframeRef.current.contentWindow.postMessage(message, this.elementProSetupUrl); } private async sendAccountDetails() { @@ -114,7 +111,7 @@ export default class EMSElementProDialog extends React.PureComponent