aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/modals
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-09-27 07:03:33 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-09-28 09:06:26 +0800
commit10345a12c2f812fabbcd9950da14beaa03cb2502 (patch)
treed4adcd2c507a2e4d40066f2d5f6285bbe14fb69a /ui/app/components/modals
parent01816e1b2216e0cf849ec3d67f01b1e571d69fa4 (diff)
downloadtangerine-wallet-browser-10345a12c2f812fabbcd9950da14beaa03cb2502.tar
tangerine-wallet-browser-10345a12c2f812fabbcd9950da14beaa03cb2502.tar.gz
tangerine-wallet-browser-10345a12c2f812fabbcd9950da14beaa03cb2502.tar.bz2
tangerine-wallet-browser-10345a12c2f812fabbcd9950da14beaa03cb2502.tar.lz
tangerine-wallet-browser-10345a12c2f812fabbcd9950da14beaa03cb2502.tar.xz
tangerine-wallet-browser-10345a12c2f812fabbcd9950da14beaa03cb2502.tar.zst
tangerine-wallet-browser-10345a12c2f812fabbcd9950da14beaa03cb2502.zip
Keep privateKey out of state and clear it after closing export private key modal.
Diffstat (limited to 'ui/app/components/modals')
-rw-r--r--ui/app/components/modals/export-private-key-modal.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/ui/app/components/modals/export-private-key-modal.js b/ui/app/components/modals/export-private-key-modal.js
index 4bb34f8c6..ddc7f1352 100644
--- a/ui/app/components/modals/export-private-key-modal.js
+++ b/ui/app/components/modals/export-private-key-modal.js
@@ -31,12 +31,20 @@ function ExportPrivateKeyModal () {
Component.call(this)
this.state = {
- password: ''
+ password: '',
+ privateKey: null,
}
}
module.exports = connect(mapStateToProps, mapDispatchToProps)(ExportPrivateKeyModal)
+ExportPrivateKeyModal.prototype.exportAccountAndGetPrivateKey = function (password, address) {
+ const { exportAccount } = this.props
+
+ exportAccount(password, address)
+ .then(privateKey => this.setState({ privateKey }))
+}
+
ExportPrivateKeyModal.prototype.renderPasswordLabel = function (privateKey) {
return h('span.private-key-password-label', privateKey
? 'This is your private key (click to copy)'
@@ -68,15 +76,13 @@ ExportPrivateKeyModal.prototype.renderButton = function (className, onClick, lab
}, label)
}
-ExportPrivateKeyModal.prototype.renderButtons = function (privateKey, password, address) {
- const { hideModal, exportAccount } = this.props
-
+ExportPrivateKeyModal.prototype.renderButtons = function (privateKey, password, address, hideModal) {
return h('div.export-private-key-buttons', {}, [
!privateKey && this.renderButton('btn-clear btn-cancel', () => hideModal(), 'Cancel'),
(privateKey
? this.renderButton('btn-clear', () => hideModal(), 'Done')
- : this.renderButton('btn-clear', () => exportAccount(this.state.password, address), 'Download')
+ : this.renderButton('btn-clear', () => this.exportAccountAndGetPrivateKey(this.state.password, address), 'Download')
),
])
@@ -86,7 +92,6 @@ ExportPrivateKeyModal.prototype.render = function () {
const {
selectedIdentity,
network,
- privateKey,
warning,
showAccountDetailModal,
hideModal,
@@ -94,6 +99,8 @@ ExportPrivateKeyModal.prototype.render = function () {
} = this.props
const { name, address } = selectedIdentity
+ const { privateKey } = this.state
+
return h(AccountModalContainer, {
showBackButton: previousModalState === 'ACCOUNT_DETAILS',
backButtonAction: () => showAccountDetailModal(),
@@ -124,7 +131,7 @@ ExportPrivateKeyModal.prototype.render = function () {
account.`
),
- this.renderButtons(privateKey, this.state.password, address),
+ this.renderButtons(privateKey, this.state.password, address, hideModal),
])
}