From c8d45cb4a8a671bad20cd5a5aa1bcbbd88463bdb Mon Sep 17 00:00:00 2001 From: Esteban MIno Date: Wed, 25 Jul 2018 20:02:12 -0400 Subject: only show retry button on earliest pending tx --- ui/app/components/tx-list-item.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index 0d693b805..92466568c 100644 --- a/ui/app/components/tx-list-item.js +++ b/ui/app/components/tx-list-item.js @@ -216,11 +216,17 @@ TxListItem.prototype.showRetryButton = function () { const currentNonce = txParams.nonce const currentNonceTxs = selectedAddressTxList.filter(tx => tx.txParams.nonce === currentNonce) const currentNonceSubmittedTxs = currentNonceTxs.filter(tx => tx.status === 'submitted') + const currentSubmittedTxs = selectedAddressTxList.filter(tx => tx.status === 'submitted') const lastSubmittedTxWithCurrentNonce = currentNonceSubmittedTxs[currentNonceSubmittedTxs.length - 1] const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce && lastSubmittedTxWithCurrentNonce.id === transactionId + const lastTx = currentSubmittedTxs.reduce((tx1, tx2) => { + if (tx1.id < tx2.id) return tx1 + return tx2 + }) + const currentTxIsLatest = lastTx.id === transactionId - return currentTxIsLatestWithNonce && Date.now() - transactionSubmittedTime > 30000 + return currentTxIsLatestWithNonce && Date.now() - transactionSubmittedTime > 30000 && currentTxIsLatest } TxListItem.prototype.setSelectedToken = function (tokenAddress) { -- cgit From b580f60d749b862fe08adfc7457c726905ebc623 Mon Sep 17 00:00:00 2001 From: Esteban MIno Date: Wed, 25 Jul 2018 20:58:20 -0400 Subject: earliest tx by submittedTime --- ui/app/components/tx-list-item.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js index 92466568c..1a639d0b9 100644 --- a/ui/app/components/tx-list-item.js +++ b/ui/app/components/tx-list-item.js @@ -213,6 +213,7 @@ TxListItem.prototype.showRetryButton = function () { if (!txParams) { return false } + let currentTxIsLatest = false const currentNonce = txParams.nonce const currentNonceTxs = selectedAddressTxList.filter(tx => tx.txParams.nonce === currentNonce) const currentNonceSubmittedTxs = currentNonceTxs.filter(tx => tx.status === 'submitted') @@ -220,11 +221,13 @@ TxListItem.prototype.showRetryButton = function () { const lastSubmittedTxWithCurrentNonce = currentNonceSubmittedTxs[currentNonceSubmittedTxs.length - 1] const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce && lastSubmittedTxWithCurrentNonce.id === transactionId - const lastTx = currentSubmittedTxs.reduce((tx1, tx2) => { - if (tx1.id < tx2.id) return tx1 - return tx2 - }) - const currentTxIsLatest = lastTx.id === transactionId + if (currentSubmittedTxs.length > 0) { + const lastTx = currentSubmittedTxs.reduce((tx1, tx2) => { + if (tx1.submittedTime < tx2.submittedTime) return tx1 + return tx2 + }) + currentTxIsLatest = lastTx.id === transactionId + } return currentTxIsLatestWithNonce && Date.now() - transactionSubmittedTime > 30000 && currentTxIsLatest } -- cgit