2021-02-04 19:15:23 +01:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Loading from '../../components/ui/loading-screen';
|
|
|
|
import { DEFAULT_ROUTE } from '../../helpers/constants/routes';
|
2020-11-09 14:50:24 +01:00
|
|
|
|
|
|
|
export default class Lock extends PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
history: PropTypes.object,
|
|
|
|
isUnlocked: PropTypes.bool,
|
|
|
|
lockMetamask: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-11-09 14:50:24 +01:00
|
|
|
|
|
|
|
componentDidMount() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { lockMetamask, isUnlocked, history } = this.props;
|
2020-11-09 14:50:24 +01:00
|
|
|
|
|
|
|
if (isUnlocked) {
|
2021-02-04 19:15:23 +01:00
|
|
|
lockMetamask().then(() => history.push(DEFAULT_ROUTE));
|
2020-11-09 14:50:24 +01:00
|
|
|
} else {
|
2021-02-04 19:15:23 +01:00
|
|
|
history.replace(DEFAULT_ROUTE);
|
2020-11-09 14:50:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
return <Loading />;
|
2020-11-09 14:50:24 +01:00
|
|
|
}
|
|
|
|
}
|