diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-10-02 08:32:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-02 08:32:47 +0800 |
commit | b11a8ca2f74af108f48604b1b427b224a9df1292 (patch) | |
tree | 8b870d4ccc788fcd74863af811441314e61d59bf /ui/app/actions.js | |
parent | f2fc91b80b30fbd5fa12d24b7bb634f1825de006 (diff) | |
parent | 65ba018aad5c09cf5f5b96df559cb543e4a9e980 (diff) | |
download | tangerine-wallet-browser-b11a8ca2f74af108f48604b1b427b224a9df1292.tar tangerine-wallet-browser-b11a8ca2f74af108f48604b1b427b224a9df1292.tar.gz tangerine-wallet-browser-b11a8ca2f74af108f48604b1b427b224a9df1292.tar.bz2 tangerine-wallet-browser-b11a8ca2f74af108f48604b1b427b224a9df1292.tar.lz tangerine-wallet-browser-b11a8ca2f74af108f48604b1b427b224a9df1292.tar.xz tangerine-wallet-browser-b11a8ca2f74af108f48604b1b427b224a9df1292.tar.zst tangerine-wallet-browser-b11a8ca2f74af108f48604b1b427b224a9df1292.zip |
Merge pull request #5329 from whymarrh/confirm-features
Add batch reject to confirm screen
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 66dc80509..8f6586139 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -167,6 +167,7 @@ var actions = { updateTransaction, updateAndApproveTx, cancelTx: cancelTx, + cancelTxs, completedTx: completedTx, txError: txError, nextTx: nextTx, @@ -1302,6 +1303,47 @@ function cancelTx (txData) { } } +/** + * Cancels all of the given transactions + * @param {Array<object>} txDataList a list of tx data objects + * @return {function(*): Promise<void>} + */ +function cancelTxs (txDataList) { + return async (dispatch, getState) => { + dispatch(actions.showLoadingIndication()) + const txIds = txDataList.map(({id}) => id) + const cancellations = txIds.map((id) => new Promise((resolve, reject) => { + background.cancelTransaction(id, (err) => { + if (err) { + return reject(err) + } + + resolve() + }) + })) + + await Promise.all(cancellations) + const newState = await updateMetamaskStateFromBackground() + dispatch(actions.updateMetamaskState(newState)) + dispatch(actions.clearSend()) + + txIds.forEach((id) => { + dispatch(actions.completedTx(id)) + }) + + dispatch(actions.hideLoadingIndication()) + + if (global.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) { + return global.platform.closeCurrentWindow() + } + } +} + +/** + * @deprecated + * @param {Array<object>} txsData + * @return {Function} + */ function cancelAllTx (txsData) { return (dispatch) => { txsData.forEach((txData, i) => { |