1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Use callback in placeSeedWord method.

When displaying seed words, we were not using a callback, which had some race condition potential.  This is simply a little cleaner and more correct.

Fixes #842
This commit is contained in:
Dan Finlay 2016-11-21 20:08:36 -08:00
parent ecfda5bcc5
commit ea56426b23
2 changed files with 10 additions and 3 deletions

View File

@ -173,10 +173,15 @@ module.exports = class KeyringController extends EventEmitter {
}) })
} }
placeSeedWords () { placeSeedWords (cb) {
const firstKeyring = this.keyrings[0] const firstKeyring = this.keyrings[0]
const seedWords = firstKeyring.serialize().mnemonic const seedWords = firstKeyring.serialize().mnemonic
this.configManager.setSeedWords(seedWords) this.configManager.setSeedWords(seedWords)
if (cb && typeof cb === 'function') {
cb()
this.emit('update')
}
} }
submitPassword (password, cb) { submitPassword (password, cb) {

View File

@ -221,9 +221,11 @@ function requestRevealSeed (password) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
background.submitPassword(password, (err) => { background.submitPassword(password, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) return dispatch(actions.displayWarning(err.message)) if (err) return dispatch(actions.displayWarning(err.message))
background.placeSeedWords() background.placeSeedWords((err) => {
if (err) return dispatch(actions.displayWarning(err.message))
dispatch(actions.hideLoadingIndication())
})
}) })
} }
} }