aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/actions.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-02-03 08:46:56 +0800
committerkumavis <aaron@kumavis.me>2017-02-03 08:46:56 +0800
commit296b2785926ffce7f65b86b12d7733111a43d30e (patch)
treef4d24d2c8eab8fa5292e4f4a5a8bb1a13db61ef9 /ui/app/actions.js
parent270808c206934cf7d75fefcdd092c9595de45f29 (diff)
downloadtangerine-wallet-browser-296b2785926ffce7f65b86b12d7733111a43d30e.tar
tangerine-wallet-browser-296b2785926ffce7f65b86b12d7733111a43d30e.tar.gz
tangerine-wallet-browser-296b2785926ffce7f65b86b12d7733111a43d30e.tar.bz2
tangerine-wallet-browser-296b2785926ffce7f65b86b12d7733111a43d30e.tar.lz
tangerine-wallet-browser-296b2785926ffce7f65b86b12d7733111a43d30e.tar.xz
tangerine-wallet-browser-296b2785926ffce7f65b86b12d7733111a43d30e.tar.zst
tangerine-wallet-browser-296b2785926ffce7f65b86b12d7733111a43d30e.zip
actions - dont expect background to provide newState, manually update
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r--ui/app/actions.js39
1 files changed, 27 insertions, 12 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index fa1e0deb5..a27ab2c14 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -158,6 +158,7 @@ var actions = {
showNewKeychain: showNewKeychain,
callBackgroundThenUpdate,
+ forceUpdateMetamaskState,
}
module.exports = actions
@@ -179,13 +180,13 @@ function tryUnlockMetamask (password) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
dispatch(actions.unlockInProgress())
- background.submitPassword(password, (err, newState) => {
+ background.submitPassword(password, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
dispatch(actions.unlockFailed(err.message))
} else {
dispatch(actions.transitionForward())
- dispatch(actions.updateMetamaskState(newState))
+ forceUpdateMetamaskState(dispatch)
}
})
}
@@ -232,16 +233,16 @@ function createNewVaultAndRestore (password, seed) {
function createNewVaultAndKeychain (password) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- background.createNewVaultAndKeychain(password, (err, newState) => {
+ background.createNewVaultAndKeychain(password, (err) => {
if (err) {
return dispatch(actions.displayWarning(err.message))
}
- background.placeSeedWords((err, newState) => {
+ background.placeSeedWords((err) => {
if (err) {
return dispatch(actions.displayWarning(err.message))
}
dispatch(actions.hideLoadingIndication())
- dispatch(actions.updateMetamaskState(newState))
+ forceUpdateMetamaskState(dispatch)
})
})
}
@@ -280,13 +281,18 @@ function addNewKeyring (type, opts) {
function importNewAccount (strategy, args) {
return (dispatch) => {
dispatch(actions.showLoadingIndication('This may take a while, be patient.'))
- background.importAccountWithStrategy(strategy, args, (err, newState) => {
+ background.importAccountWithStrategy(strategy, args, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) return dispatch(actions.displayWarning(err.message))
- dispatch(actions.updateMetamaskState(newState))
- dispatch({
- type: actions.SHOW_ACCOUNT_DETAIL,
- value: newState.selectedAddress,
+ background.getState((err, newState) => {
+ if (err) {
+ return dispatch(actions.displayWarning(err.message))
+ }
+ dispatch(actions.updateMetamaskState(newState))
+ dispatch({
+ type: actions.SHOW_ACCOUNT_DETAIL,
+ value: newState.selectedAddress,
+ })
})
})
}
@@ -876,12 +882,21 @@ function shapeShiftRequest (query, options, cb) {
function callBackgroundThenUpdate (method, ...args) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- method.call(background, ...args, (err, newState) => {
+ method.call(background, ...args, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
return dispatch(actions.displayWarning(err.message))
}
- dispatch(actions.updateMetamaskState(newState))
+ forceUpdateMetamaskState(dispatch)
})
}
}
+
+function forceUpdateMetamaskState(dispatch){
+ background.getState((err, newState) => {
+ if (err) {
+ return dispatch(actions.displayWarning(err.message))
+ }
+ dispatch(actions.updateMetamaskState(newState))
+ })
+} \ No newline at end of file