lbry-desktop/ui/modal/modalWalletDecrypt/view.jsx

64 lines
1.5 KiB
React
Raw Permalink Normal View History

2018-07-18 21:48:30 +02:00
// @flow
import React from 'react';
import { Modal } from 'modal/modal';
import Button from 'component/button';
2019-09-26 18:07:11 +02:00
import { deleteAuthToken } from 'util/saved-passwords';
2018-07-18 21:48:30 +02:00
type Props = {
closeModal: () => void,
2018-09-26 19:48:07 +02:00
decryptWallet: () => void,
2019-01-19 19:54:06 +01:00
updateWalletStatus: () => void,
2018-07-18 21:48:30 +02:00
walletDecryptSucceded: boolean,
};
2019-01-19 19:54:06 +01:00
type State = {
submitted: boolean,
};
class ModalWalletDecrypt extends React.PureComponent<Props, State> {
2018-07-18 21:48:30 +02:00
state = {
submitted: false, // Prior actions could be marked complete
};
componentDidUpdate() {
const { props, state } = this;
if (state.submitted && props.walletDecryptSucceded === true) {
2019-09-26 18:07:11 +02:00
deleteAuthToken();
2018-07-18 21:48:30 +02:00
props.closeModal();
props.updateWalletStatus();
}
}
2018-09-26 19:48:07 +02:00
submitDecryptForm() {
this.setState({ submitted: true });
this.props.decryptWallet();
}
2018-07-18 21:48:30 +02:00
render() {
2018-10-19 22:38:07 +02:00
const { closeModal } = this.props;
2018-07-18 21:48:30 +02:00
return (
<Modal
isOpen
2020-08-26 22:28:33 +02:00
title={__('Decrypt wallet')}
contentLabel={__('Decrypt wallet')}
2018-07-18 21:48:30 +02:00
type="confirm"
2020-08-26 22:28:33 +02:00
confirmButtonLabel={__('Decrypt wallet')}
2018-07-18 21:48:30 +02:00
abortButtonLabel={__('Cancel')}
onConfirmed={() => this.submitDecryptForm()}
onAborted={closeModal}
>
2019-07-21 23:31:22 +02:00
<p>
{__(
'Your wallet has been encrypted with a local password, performing this action will remove this password.'
)}{' '}
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/wallet-encryption" />.
</p>
2018-07-18 21:48:30 +02:00
</Modal>
);
}
}
export default ModalWalletDecrypt;