Fix state updating after vault creation and unlocking

feature/default_network_editable
Dan Finlay 8 years ago
parent 2132477797
commit e5c95d68f8
  1. 4
      app/scripts/keyring-controller.js
  2. 10
      ui/app/actions.js
  3. 1
      ui/app/app.js

@ -72,7 +72,7 @@ module.exports = class KeyringController extends EventEmitter {
}) })
.then((encryptedString) => { .then((encryptedString) => {
this.configManager.setVault(encryptedString) this.configManager.setVault(encryptedString)
cb(null, []) cb(null, this.getState())
}) })
.catch((err) => { .catch((err) => {
cb(err) cb(err)
@ -82,7 +82,7 @@ module.exports = class KeyringController extends EventEmitter {
submitPassword(password, cb) { submitPassword(password, cb) {
this.loadKey(password) this.loadKey(password)
.then((key) => { .then((key) => {
cb(null, []) cb(null, this.getState())
}) })
.catch((err) => { .catch((err) => {
cb(err) cb(err)

@ -157,11 +157,16 @@ function tryUnlockMetamask (password) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
dispatch(actions.unlockInProgress()) dispatch(actions.unlockInProgress())
background.submitPassword(password, (err, selectedAccount) => { background.submitPassword(password, (err, newState) => {
dispatch(actions.hideLoadingIndication()) dispatch(actions.hideLoadingIndication())
if (err) { if (err) {
dispatch(actions.unlockFailed()) dispatch(actions.unlockFailed())
} else { } else {
dispatch(this.updateMetamaskState(newState))
let selectedAccount
try {
selectedAccount = newState.metamask.selectedAccount
} catch (e) {}
dispatch(actions.unlockMetamask(selectedAccount)) dispatch(actions.unlockMetamask(selectedAccount))
} }
}) })
@ -171,10 +176,11 @@ function tryUnlockMetamask (password) {
function createNewVault (password, entropy) { function createNewVault (password, entropy) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.createNewVaultInProgress()) dispatch(actions.createNewVaultInProgress())
background.createNewVault(password, entropy, (err, result) => { background.createNewVault(password, entropy, (err, newState) => {
if (err) { if (err) {
return dispatch(actions.showWarning(err.message)) return dispatch(actions.showWarning(err.message))
} }
dispatch(this.updateMetamaskState(newState))
dispatch(this.showAccountsPage()) dispatch(this.showAccountsPage())
dispatch(this.hideLoadingIndication()) dispatch(this.hideLoadingIndication())
}) })

@ -402,6 +402,7 @@ App.prototype.renderPrimary = function () {
// show initialize screen // show initialize screen
if (!props.isInitialized || props.forgottenPassword) { if (!props.isInitialized || props.forgottenPassword) {
// show current view // show current view
switch (props.currentView.name) { switch (props.currentView.name) {

Loading…
Cancel
Save