diff options
author | Dan <danjm.com@gmail.com> | 2018-04-10 03:22:26 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2018-04-10 03:22:26 +0800 |
commit | 2c4426e4de745be880a994674dc1dc74c7ec74eb (patch) | |
tree | 1de9b836026d3222b490793099b66372404b83ab /app/scripts/migrations/023.js | |
parent | 9dbb9d12ad31d53b8911db171cb7d6b3fcb477e2 (diff) | |
parent | 4cae3d3b0d2a9cc0279e44de256e7fc7e219dca1 (diff) | |
download | tangerine-wallet-browser-2c4426e4de745be880a994674dc1dc74c7ec74eb.tar.gz tangerine-wallet-browser-2c4426e4de745be880a994674dc1dc74c7ec74eb.tar.zst tangerine-wallet-browser-2c4426e4de745be880a994674dc1dc74c7ec74eb.zip |
Merge branch 'master' into i3580-InternationalizeCurrency
Diffstat (limited to 'app/scripts/migrations/023.js')
-rw-r--r-- | app/scripts/migrations/023.js | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/app/scripts/migrations/023.js b/app/scripts/migrations/023.js index bce0a5bea..151496b06 100644 --- a/app/scripts/migrations/023.js +++ b/app/scripts/migrations/023.js @@ -28,23 +28,27 @@ module.exports = { function transformState (state) { const newState = state - const transactions = newState.TransactionController.transactions - - if (transactions.length <= 40) return newState - - let reverseTxList = transactions.reverse() - let stripping = true - while (reverseTxList.length > 40 && stripping) { - let txIndex = reverseTxList.findIndex((txMeta) => { - return (txMeta.status === 'failed' || - txMeta.status === 'rejected' || - txMeta.status === 'confirmed' || - txMeta.status === 'dropped') - }) - if (txIndex < 0) stripping = false - else reverseTxList.splice(txIndex, 1) - } - newState.TransactionController.transactions = reverseTxList.reverse() + const { TransactionController } = newState + if (TransactionController && TransactionController.transactions) { + const transactions = newState.TransactionController.transactions + + if (transactions.length <= 40) return newState + + let reverseTxList = transactions.reverse() + let stripping = true + while (reverseTxList.length > 40 && stripping) { + let txIndex = reverseTxList.findIndex((txMeta) => { + return (txMeta.status === 'failed' || + txMeta.status === 'rejected' || + txMeta.status === 'confirmed' || + txMeta.status === 'dropped') + }) + if (txIndex < 0) stripping = false + else reverseTxList.splice(txIndex, 1) + } + + newState.TransactionController.transactions = reverseTxList.reverse() + } return newState } |