aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/store/actions.js
diff options
context:
space:
mode:
authorMark Stacey <markjstacey@gmail.com>2019-09-01 00:34:27 +0800
committerGitHub <noreply@github.com>2019-09-01 00:34:27 +0800
commitdaa20b4b63dc0509ac4911ebbb1bf7534e299fd6 (patch)
tree9f251186d26cc26ab6a69598a83ae976af472f4e /ui/app/store/actions.js
parent0f1edce403bd6fcb8a6efacf1fe537c0ca8f9134 (diff)
downloadtangerine-wallet-browser-daa20b4b63dc0509ac4911ebbb1bf7534e299fd6.tar.gz
tangerine-wallet-browser-daa20b4b63dc0509ac4911ebbb1bf7534e299fd6.tar.zst
tangerine-wallet-browser-daa20b4b63dc0509ac4911ebbb1bf7534e299fd6.zip
Return after rejecting promise in action (#7079)
* Add missing test descriptions * Fix async tests that expect a rejection These tests expected the function under test to return a rejected promise, and had assertions to be run in the `catch` clause. However, the tests would still pass if the function didn't reject, with the assertions never being run. The tests have been updated to fail if the function doesn't throw. * Handle ignored promise rejection In the case where `forceUpdateMetamaskState` rejects, the function `setSeedPhraseBackedUp` would never resolve. It has been updated to pass along the rejection instead. * Return after rejecting promise in action A few actions would continue after encountering an error, resulting in errors being compounded. Instead all actions will now return after encountering an error (which it looks like was the intention in these cases anyway).
Diffstat (limited to 'ui/app/store/actions.js')
-rw-r--r--ui/app/store/actions.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js
index cbf8e6283..2b0b54c60 100644
--- a/ui/app/store/actions.js
+++ b/ui/app/store/actions.js
@@ -1196,7 +1196,7 @@ function updateAndApproveTx (txData) {
dispatch(actions.txError(err))
dispatch(actions.goHome())
log.error(err.message)
- reject(err)
+ return reject(err)
}
resolve(txData)
@@ -1679,7 +1679,7 @@ function addToken (address, symbol, decimals, image) {
dispatch(actions.hideLoadingIndication())
if (err) {
dispatch(actions.displayWarning(err.message))
- reject(err)
+ return reject(err)
}
dispatch(actions.updateTokens(tokens))
resolve(tokens)
@@ -1696,7 +1696,7 @@ function removeToken (address) {
dispatch(actions.hideLoadingIndication())
if (err) {
dispatch(actions.displayWarning(err.message))
- reject(err)
+ return reject(err)
}
dispatch(actions.updateTokens(tokens))
resolve(tokens)
@@ -1786,7 +1786,7 @@ function retryTransaction (txId, gasPrice) {
background.retryTransaction(txId, gasPrice, (err, newState) => {
if (err) {
dispatch(actions.displayWarning(err.message))
- reject(err)
+ return reject(err)
}
const { selectedAddressTxList } = newState
@@ -1809,7 +1809,7 @@ function createCancelTransaction (txId, customGasPrice) {
background.createCancelTransaction(txId, customGasPrice, (err, newState) => {
if (err) {
dispatch(actions.displayWarning(err.message))
- reject(err)
+ return reject(err)
}
const { selectedAddressTxList } = newState
@@ -1832,7 +1832,7 @@ function createSpeedUpTransaction (txId, customGasPrice) {
background.createSpeedUpTransaction(txId, customGasPrice, (err, newState) => {
if (err) {
dispatch(actions.displayWarning(err.message))
- reject(err)
+ return reject(err)
}
const { selectedAddressTxList } = newState
@@ -2185,7 +2185,7 @@ function setAccountLabel (account, label) {
if (err) {
dispatch(actions.displayWarning(err.message))
- reject(err)
+ return reject(err)
}
dispatch({
@@ -2786,7 +2786,9 @@ function setSeedPhraseBackedUp (seedPhraseBackupState) {
dispatch(actions.displayWarning(err.message))
return reject(err)
}
- return forceUpdateMetamaskState(dispatch).then(() => resolve())
+ return forceUpdateMetamaskState(dispatch)
+ .then(resolve)
+ .catch(reject)
})
})
}