Properly type Modal props to ensure useful typescript checking (#10238

* Properly type Modal props to ensure useful typescript checking

* delint

* Iterate

* Iterate

* Fix modal.close loop

* Iterate

* Fix tests

* Add comment

* Fix test
This commit is contained in:
Michael Telatyński 2023-02-28 10:31:48 +00:00 committed by GitHub
parent ae5725b24c
commit 629e5cb01f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
124 changed files with 600 additions and 560 deletions

View file

@ -24,14 +24,14 @@ import BaseDialog from "./BaseDialog";
import EncryptionPanel from "../right_panel/EncryptionPanel";
interface IProps {
verificationRequest: VerificationRequest;
verificationRequestPromise: Promise<VerificationRequest>;
verificationRequest?: VerificationRequest;
verificationRequestPromise?: Promise<VerificationRequest>;
onFinished: () => void;
member: User;
member?: User;
}
interface IState {
verificationRequest: VerificationRequest;
verificationRequest?: VerificationRequest;
}
export default class VerificationRequestDialog extends React.Component<IProps, IState> {
@ -40,18 +40,16 @@ export default class VerificationRequestDialog extends React.Component<IProps, I
this.state = {
verificationRequest: this.props.verificationRequest,
};
if (this.props.verificationRequestPromise) {
this.props.verificationRequestPromise.then((r) => {
this.setState({ verificationRequest: r });
});
}
this.props.verificationRequestPromise?.then((r) => {
this.setState({ verificationRequest: r });
});
}
public render(): React.ReactNode {
const request = this.state.verificationRequest;
const otherUserId = request && request.otherUserId;
const member = this.props.member || (otherUserId && MatrixClientPeg.get().getUser(otherUserId));
const title = request && request.isSelfVerification ? _t("Verify other device") : _t("Verification Request");
const otherUserId = request?.otherUserId;
const member = this.props.member || (otherUserId ? MatrixClientPeg.get().getUser(otherUserId) : null);
const title = request?.isSelfVerification ? _t("Verify other device") : _t("Verification Request");
return (
<BaseDialog