1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/ui/pages/unlock-page/unlock-page.container.js
David Walsh 6cc46454c2
UX: Remove legacy metametrics modal (#17817)
* UX: Remove legacy metametrics modal

* Remove old localizations

* Remove dead image
2023-02-23 13:58:09 -06:00

72 lines
1.8 KiB
JavaScript

import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { compose } from 'redux';
import { getEnvironmentType } from '../../../app/scripts/lib/util';
import { ENVIRONMENT_TYPE_POPUP } from '../../../shared/constants/app';
import {
DEFAULT_ROUTE,
RESTORE_VAULT_ROUTE,
} from '../../helpers/constants/routes';
import {
tryUnlockMetamask,
markPasswordForgotten,
forceUpdateMetamaskState,
} from '../../store/actions';
import UnlockPage from './unlock-page.component';
const mapStateToProps = (state) => {
const {
metamask: { isUnlocked },
} = state;
return {
isUnlocked,
};
};
const mapDispatchToProps = (dispatch) => {
return {
tryUnlockMetamask: (password) => dispatch(tryUnlockMetamask(password)),
markPasswordForgotten: () => dispatch(markPasswordForgotten()),
forceUpdateMetamaskState: () => forceUpdateMetamaskState(dispatch),
};
};
const mergeProps = (stateProps, dispatchProps, ownProps) => {
const {
// eslint-disable-next-line no-shadow
markPasswordForgotten,
// eslint-disable-next-line no-shadow
tryUnlockMetamask,
...restDispatchProps
} = dispatchProps;
const { history, onSubmit: ownPropsSubmit, ...restOwnProps } = ownProps;
const onImport = async () => {
await markPasswordForgotten();
history.push(RESTORE_VAULT_ROUTE);
if (getEnvironmentType() === ENVIRONMENT_TYPE_POPUP) {
global.platform.openExtensionInBrowser(RESTORE_VAULT_ROUTE);
}
};
const onSubmit = async (password) => {
await tryUnlockMetamask(password);
history.push(DEFAULT_ROUTE);
};
return {
...stateProps,
...restDispatchProps,
...restOwnProps,
onRestore: onImport,
onSubmit: ownPropsSubmit || onSubmit,
history,
};
};
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps, mergeProps),
)(UnlockPage);