diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-05-01 01:42:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 01:42:27 +0800 |
commit | 099fc0917dd5d281b60e2879bd1f555fe0988981 (patch) | |
tree | 854d2e5993629d6a276b9596bd51a6cf18327834 /app | |
parent | aa3dc83bf046d4c84d83976238c032dfeb953014 (diff) | |
parent | 98ae853b6c67bce137df00c2527e5ece25f1129e (diff) | |
download | tangerine-wallet-browser-099fc0917dd5d281b60e2879bd1f555fe0988981.tar tangerine-wallet-browser-099fc0917dd5d281b60e2879bd1f555fe0988981.tar.gz tangerine-wallet-browser-099fc0917dd5d281b60e2879bd1f555fe0988981.tar.bz2 tangerine-wallet-browser-099fc0917dd5d281b60e2879bd1f555fe0988981.tar.lz tangerine-wallet-browser-099fc0917dd5d281b60e2879bd1f555fe0988981.tar.xz tangerine-wallet-browser-099fc0917dd5d281b60e2879bd1f555fe0988981.tar.zst tangerine-wallet-browser-099fc0917dd5d281b60e2879bd1f555fe0988981.zip |
Merge pull request #4131 from MetaMask/emitter-cleanup
transactions - run event emitters outside context of _setTxStatus
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/controllers/transactions/tx-state-manager.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index 53428c333..f05c7d095 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -2,6 +2,7 @@ const extend = require('xtend') const EventEmitter = require('events') const ObservableStore = require('obs-store') const ethUtil = require('ethereumjs-util') +const log = require('loglevel') const txStateHistoryHelper = require('./lib/tx-state-history-helper') const createId = require('../../lib/random-id') const { getFinalStates } = require('./lib/util') @@ -398,13 +399,19 @@ class TransactionStateManager extends EventEmitter { _setTxStatus (txId, status) { const txMeta = this.getTx(txId) txMeta.status = status - this.emit(`${txMeta.id}:${status}`, txId) - this.emit(`tx:status-update`, txId, status) - if (['submitted', 'rejected', 'failed'].includes(status)) { - this.emit(`${txMeta.id}:finished`, txMeta) - } - this.updateTx(txMeta, `txStateManager: setting status to ${status}`) - this.emit('update:badge') + setTimeout(() => { + try { + this.updateTx(txMeta, `txStateManager: setting status to ${status}`) + this.emit(`${txMeta.id}:${status}`, txId) + this.emit(`tx:status-update`, txId, status) + if (['submitted', 'rejected', 'failed'].includes(status)) { + this.emit(`${txMeta.id}:finished`, txMeta) + } + this.emit('update:badge') + } catch (error) { + log.error(error) + } + }) } /** |