mirror of https://github.com/vector-im/riot-web
Migrate SetupEncryptionDialog to TypeScript
parent
0909112fa9
commit
68db2438ea
|
@ -15,14 +15,13 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import SetupEncryptionBody from '../../../structures/auth/SetupEncryptionBody';
|
import SetupEncryptionBody from '../../../structures/auth/SetupEncryptionBody';
|
||||||
import BaseDialog from '../BaseDialog';
|
import BaseDialog from '../BaseDialog';
|
||||||
import { _t } from '../../../../languageHandler';
|
import { _t } from '../../../../languageHandler';
|
||||||
import { SetupEncryptionStore, PHASE_DONE } from '../../../../stores/SetupEncryptionStore';
|
import { SetupEncryptionStore, PHASE_DONE } from '../../../../stores/SetupEncryptionStore';
|
||||||
import {replaceableComponent} from "../../../../utils/replaceableComponent";
|
import {replaceableComponent} from "../../../../utils/replaceableComponent";
|
||||||
|
|
||||||
function iconFromPhase(phase) {
|
function iconFromPhase(phase: string) {
|
||||||
if (phase === PHASE_DONE) {
|
if (phase === PHASE_DONE) {
|
||||||
return require("../../../../../res/img/e2e/verified.svg");
|
return require("../../../../../res/img/e2e/verified.svg");
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,32 +29,38 @@ function iconFromPhase(phase) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.dialogs.security.SetupEncryptionDialog")
|
interface IProps {
|
||||||
export default class SetupEncryptionDialog extends React.Component {
|
onFinished: (success: boolean) => void;
|
||||||
static propTypes = {
|
}
|
||||||
onFinished: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor() {
|
interface IState {
|
||||||
super();
|
icon: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
@replaceableComponent("views.dialogs.security.SetupEncryptionDialog")
|
||||||
|
export default class SetupEncryptionDialog extends React.Component<IProps, IState> {
|
||||||
|
private store: SetupEncryptionStore;
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
this.store = SetupEncryptionStore.sharedInstance();
|
this.store = SetupEncryptionStore.sharedInstance();
|
||||||
this.state = {icon: iconFromPhase(this.store.phase)};
|
this.state = {icon: iconFromPhase(this.store.phase)};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
public componentDidMount() {
|
||||||
this.store.on("update", this._onStoreUpdate);
|
this.store.on("update", this.onStoreUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
this.store.removeListener("update", this._onStoreUpdate);
|
this.store.removeListener("update", this.onStoreUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onStoreUpdate = () => {
|
private onStoreUpdate = (): void => {
|
||||||
this.setState({icon: iconFromPhase(this.store.phase)});
|
this.setState({icon: iconFromPhase(this.store.phase)});
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
public render() {
|
||||||
return <BaseDialog
|
return <BaseDialog
|
||||||
headerImage={this.state.icon}
|
headerImage={this.state.icon}
|
||||||
onFinished={this.props.onFinished}
|
onFinished={this.props.onFinished}
|
Loading…
Reference in New Issue