Basic ts-ification of SetupEncryptionBody
This commit is contained in:
parent
8520a11fc3
commit
46b2f0404a
2 changed files with 27 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
Copyright 2020-2021 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -15,7 +15,6 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
|
@ -23,23 +22,31 @@ import VerificationRequestDialog from '../../views/dialogs/VerificationRequestDi
|
||||||
import * as sdk from '../../../index';
|
import * as sdk from '../../../index';
|
||||||
import { SetupEncryptionStore, Phase } from '../../../stores/SetupEncryptionStore';
|
import { SetupEncryptionStore, Phase } from '../../../stores/SetupEncryptionStore';
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
|
import { ISecretStorageKeyInfo } from 'matrix-js-sdk';
|
||||||
|
import EncryptionPanel from "../../views/right_panel/EncryptionPanel"
|
||||||
|
|
||||||
function keyHasPassphrase(keyInfo) {
|
function keyHasPassphrase(keyInfo: ISecretStorageKeyInfo): boolean {
|
||||||
return (
|
return Boolean(
|
||||||
keyInfo.passphrase &&
|
keyInfo.passphrase &&
|
||||||
keyInfo.passphrase.salt &&
|
keyInfo.passphrase.salt &&
|
||||||
keyInfo.passphrase.iterations
|
keyInfo.passphrase.iterations
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@replaceableComponent("structures.auth.SetupEncryptionBody")
|
interface IProps {
|
||||||
export default class SetupEncryptionBody extends React.Component {
|
onFinished: (boolean) => void;
|
||||||
static propTypes = {
|
}
|
||||||
onFinished: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor() {
|
interface IState {
|
||||||
super();
|
phase: Phase;
|
||||||
|
verificationRequest: any;
|
||||||
|
backupInfo: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
@replaceableComponent("structures.auth.SetupEncryptionBody")
|
||||||
|
export default class SetupEncryptionBody extends React.Component<IProps, IState> {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
const store = SetupEncryptionStore.sharedInstance();
|
const store = SetupEncryptionStore.sharedInstance();
|
||||||
store.on("update", this._onStoreUpdate);
|
store.on("update", this._onStoreUpdate);
|
||||||
store.start();
|
store.start();
|
||||||
|
@ -56,7 +63,7 @@ export default class SetupEncryptionBody extends React.Component {
|
||||||
_onStoreUpdate = () => {
|
_onStoreUpdate = () => {
|
||||||
const store = SetupEncryptionStore.sharedInstance();
|
const store = SetupEncryptionStore.sharedInstance();
|
||||||
if (store.phase === Phase.Finished) {
|
if (store.phase === Phase.Finished) {
|
||||||
this.props.onFinished();
|
this.props.onFinished(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -113,6 +120,10 @@ export default class SetupEncryptionBody extends React.Component {
|
||||||
store.done();
|
store.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onEncryptionPanelClose = () => {
|
||||||
|
this.props.onFinished(false);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
|
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
|
||||||
|
|
||||||
|
@ -121,12 +132,13 @@ export default class SetupEncryptionBody extends React.Component {
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
if (this.state.verificationRequest) {
|
if (this.state.verificationRequest) {
|
||||||
const EncryptionPanel = sdk.getComponent("views.right_panel.EncryptionPanel");
|
|
||||||
return <EncryptionPanel
|
return <EncryptionPanel
|
||||||
layout="dialog"
|
layout="dialog"
|
||||||
|
inDialog={true}
|
||||||
verificationRequest={this.state.verificationRequest}
|
verificationRequest={this.state.verificationRequest}
|
||||||
onClose={this.props.onFinished}
|
onClose={this.onEncryptionPanelClose}
|
||||||
member={MatrixClientPeg.get().getUser(this.state.verificationRequest.otherUserId)}
|
member={MatrixClientPeg.get().getUser(this.state.verificationRequest.otherUserId)}
|
||||||
|
isRoomEncrypted={false}
|
||||||
/>;
|
/>;
|
||||||
} else if (phase === Phase.Intro) {
|
} else if (phase === Phase.Intro) {
|
||||||
const store = SetupEncryptionStore.sharedInstance();
|
const store = SetupEncryptionStore.sharedInstance();
|
|
@ -39,7 +39,7 @@ interface IProps {
|
||||||
member: RoomMember | User;
|
member: RoomMember | User;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
verificationRequest: VerificationRequest;
|
verificationRequest: VerificationRequest;
|
||||||
verificationRequestPromise: Promise<VerificationRequest>;
|
verificationRequestPromise?: Promise<VerificationRequest>;
|
||||||
layout: string;
|
layout: string;
|
||||||
inDialog: boolean;
|
inDialog: boolean;
|
||||||
isRoomEncrypted: boolean;
|
isRoomEncrypted: boolean;
|
||||||
|
|
Loading…
Reference in a new issue