aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r--ui/app/actions.js35
1 files changed, 22 insertions, 13 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 339c28be3..a2106ea85 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -1,4 +1,6 @@
var actions = {
+ GO_HOME: 'GO_HOME',
+ goHome: goHome,
// remote state
UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE',
updateMetamaskState: updateMetamaskState,
@@ -87,24 +89,29 @@ var actions = {
module.exports = actions
-
var _accountManager = null
function _setAccountManager(accountManager){
_accountManager = accountManager
}
+function goHome() {
+ return {
+ type: this.GO_HOME,
+ }
+}
+
// async actions
function tryUnlockMetamask(password) {
return (dispatch) => {
dispatch(this.unlockInProgress())
- _accountManager.submitPassword(password, (err) => {
+ _accountManager.submitPassword(password, (err, selectedAccount) => {
dispatch(this.hideLoadingIndication())
if (err) {
dispatch(this.unlockFailed())
} else {
dispatch(this.unlockMetamask())
- dispatch(this.setSelectedAddress())
+ dispatch(this.showAccountDetail(selectedAccount))
}
})
}
@@ -123,7 +130,7 @@ function recoverFromSeed(password, seed) {
return (dispatch) => {
// dispatch(this.createNewVaultInProgress())
dispatch(this.showLoadingIndication())
- _accountManager.recoverFromSeed(password, seed, (err, result) => {
+ _accountManager.recoverFromSeed(password, seed, (err, selectedAccount) => {
if (err) {
dispatch(this.hideLoadingIndication())
var message = err.message
@@ -131,11 +138,9 @@ function recoverFromSeed(password, seed) {
}
dispatch(this.unlockMetamask())
- dispatch(this.setSelectedAddress())
- dispatch(this.updateMetamaskState(result))
+ dispatch(this.showAccountDetail(selectedAccount))
dispatch(this.hideLoadingIndication())
- dispatch(this.showAccountsPage())
- })
+ })
}
}
@@ -276,9 +281,13 @@ function lockMetamask() {
}
function showAccountDetail(address) {
- return {
- type: this.SHOW_ACCOUNT_DETAIL,
- value: address,
+ return (dispatch) => {
+ _accountManager.setSelectedAddress(address)
+
+ dispatch({
+ type: this.SHOW_ACCOUNT_DETAIL,
+ value: address,
+ })
}
}
@@ -297,10 +306,10 @@ function clearSeedWordCache() {
function confirmSeedWords() {
return (dispatch) => {
dispatch(this.showLoadingIndication())
- _accountManager.clearSeedWordCache((err) => {
+ _accountManager.clearSeedWordCache((err, accounts) => {
dispatch(this.clearSeedWordCache())
console.log('Seed word cache cleared.')
- dispatch(this.setSelectedAddress())
+ dispatch(this.showAccountDetail(accounts[0].address))
})
}
}