aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-05-13 16:13:14 +0800
committerDan Finlay <dan@danfinlay.com>2016-05-13 16:24:05 +0800
commit041b5493dc43c9f8b69dc5a1dde4b319638618a7 (patch)
treed74812d939398896cc275bbf4080faa26aa35e95 /ui
parentf2676d12413e379f3876e8e36b73478c66ed6ad0 (diff)
downloadtangerine-wallet-browser-041b5493dc43c9f8b69dc5a1dde4b319638618a7.tar
tangerine-wallet-browser-041b5493dc43c9f8b69dc5a1dde4b319638618a7.tar.gz
tangerine-wallet-browser-041b5493dc43c9f8b69dc5a1dde4b319638618a7.tar.bz2
tangerine-wallet-browser-041b5493dc43c9f8b69dc5a1dde4b319638618a7.tar.lz
tangerine-wallet-browser-041b5493dc43c9f8b69dc5a1dde4b319638618a7.tar.xz
tangerine-wallet-browser-041b5493dc43c9f8b69dc5a1dde4b319638618a7.tar.zst
tangerine-wallet-browser-041b5493dc43c9f8b69dc5a1dde4b319638618a7.zip
Streamlined some transition logic
Fixes #122 Had used multiple actions for some transitions, which would lead to brief intermediary states. Now making a few actions much more explicit about what they route to, so there is less intermediary logic, and we can transition confidently to the correct view.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/account-detail.js4
-rw-r--r--ui/app/actions.js24
-rw-r--r--ui/app/reducers/metamask.js8
3 files changed, 22 insertions, 14 deletions
diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js
index a71e85da8..5c33c3421 100644
--- a/ui/app/account-detail.js
+++ b/ui/app/account-detail.js
@@ -62,7 +62,7 @@ AccountDetailScreen.prototype.render = function() {
h('.identicon-wrapper.flex-column.flex-center.select-none', [
h(Identicon, {
diameter: 62,
- address: account.address
+ address: selected,
}),
]),
@@ -90,7 +90,7 @@ AccountDetailScreen.prototype.render = function() {
style: {
'line-height': 16,
},
- }, addressSummary(account.address)),
+ }, addressSummary(selected)),
h('i.fa.fa-download.fa-md.cursor-pointer.color-orange', {
onClick: () => this.requestAccountExport(account.address),
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 45af35e67..f489eede7 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -114,7 +114,7 @@ function tryUnlockMetamask(password) {
if (err) {
dispatch(this.unlockFailed())
} else {
- dispatch(this.unlockMetamask())
+ dispatch(this.unlockMetamask(selectedAccount))
}
})
}
@@ -133,12 +133,12 @@ function recoverFromSeed(password, seed) {
return (dispatch) => {
// dispatch(this.createNewVaultInProgress())
dispatch(this.showLoadingIndication())
- _accountManager.recoverFromSeed(password, seed, (err, selectedAccount) => {
+ _accountManager.recoverFromSeed(password, seed, (err, metamaskState) => {
dispatch(this.hideLoadingIndication())
if (err) return dispatch(this.displayWarning(err.message))
- dispatch(this.goHome())
- dispatch(this.unlockMetamask())
+ var account = Object.keys(metamaskState.identities)[0]
+ dispatch(this.unlockMetamask(account))
})
}
}
@@ -271,9 +271,10 @@ function unlockFailed() {
}
}
-function unlockMetamask() {
+function unlockMetamask(account) {
return {
type: this.UNLOCK_METAMASK,
+ value: account,
}
}
@@ -297,11 +298,13 @@ function lockMetamask() {
function showAccountDetail(address) {
return (dispatch) => {
- _accountManager.setSelectedAddress(address)
-
- dispatch({
- type: this.SHOW_ACCOUNT_DETAIL,
- value: address,
+ dispatch(this.showLoadingIndication())
+ _accountManager.setSelectedAddress(address, (err, address) => {
+ dispatch(this.hideLoadingIndication())
+ dispatch({
+ type: this.SHOW_ACCOUNT_DETAIL,
+ value: address,
+ })
})
}
}
@@ -323,7 +326,6 @@ function confirmSeedWords() {
return (dispatch) => {
dispatch(this.showLoadingIndication())
_accountManager.clearSeedWordCache((err, account) => {
- dispatch(this.clearSeedWordCache(account))
console.log('Seed word cache cleared. ' + account)
dispatch(this.showAccountDetail(account))
})
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js
index 8bf5c8aae..8628e84d2 100644
--- a/ui/app/reducers/metamask.js
+++ b/ui/app/reducers/metamask.js
@@ -29,6 +29,7 @@ function reduceMetamask(state, action) {
return extend(metamaskState, {
isUnlocked: true,
isInitialized: true,
+ selectedAccount: action.value,
})
case actions.LOCK_METAMASK:
@@ -85,9 +86,14 @@ function reduceMetamask(state, action) {
return newState
case actions.SHOW_ACCOUNT_DETAIL:
- return extend(metamaskState, {
+ const newState = extend(metamaskState, {
+ isUnlocked: true,
+ isInitialized: true,
selectedAccount: action.value,
+ selectedAddress: action.value,
})
+ delete newState.seedWords
+ return newState
default:
return metamaskState