diff options
Make account detail view the primary view
- When unlocking, the first account is now selected by default and displayed as the main view.
- There is now a "CHANGE ACCT" button on the detail view to show the accounts list.
- Clicking an account from the accounts list now navigates to the detail view and selects that account.
- Config/Info screen "back" buttons now fire a new action, `GO_HOME`, which is configured to navigate to the accountDetail view, putting that logic in one place.
- When locking and unlocking again, the first account is always displayed, eventually we should persist the selection.
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 339c28be3..e2d81883f 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, accounts) => { dispatch(this.hideLoadingIndication()) if (err) { dispatch(this.unlockFailed()) } else { dispatch(this.unlockMetamask()) - dispatch(this.setSelectedAddress()) + dispatch(this.showAccountDetail(accounts[0].address)) } }) } @@ -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, accounts) => { 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(accounts[0].address)) dispatch(this.hideLoadingIndication()) - dispatch(this.showAccountsPage()) - }) + }) } } @@ -297,10 +302,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)) }) } } |