mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #4885 from MetaMask/RetryOnEarliestPendingTx
Only show retry button on the earliest pending tx
This commit is contained in:
commit
53b440a287
@ -36,14 +36,23 @@ TransactionListItem.prototype.showRetryButton = function () {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let currentTxIsLatest = false
|
||||||
const currentNonce = txParams.nonce
|
const currentNonce = txParams.nonce
|
||||||
const currentNonceTxs = transactions.filter(tx => tx.txParams.nonce === currentNonce)
|
const currentNonceTxs = transactions.filter(tx => tx.txParams.nonce === currentNonce)
|
||||||
const currentNonceSubmittedTxs = currentNonceTxs.filter(tx => tx.status === 'submitted')
|
const currentNonceSubmittedTxs = currentNonceTxs.filter(tx => tx.status === 'submitted')
|
||||||
|
const currentSubmittedTxs = transactions.filter(tx => tx.status === 'submitted')
|
||||||
const lastSubmittedTxWithCurrentNonce = currentNonceSubmittedTxs[0]
|
const lastSubmittedTxWithCurrentNonce = currentNonceSubmittedTxs[0]
|
||||||
const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce &&
|
const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce &&
|
||||||
lastSubmittedTxWithCurrentNonce.id === transaction.id
|
lastSubmittedTxWithCurrentNonce.id === transaction.id
|
||||||
|
if (currentSubmittedTxs.length > 0) {
|
||||||
|
const lastTx = currentSubmittedTxs.reduce((tx1, tx2) => {
|
||||||
|
if (tx1.submittedTime < tx2.submittedTime) return tx1
|
||||||
|
return tx2
|
||||||
|
})
|
||||||
|
currentTxIsLatest = lastTx.id === transaction.id
|
||||||
|
}
|
||||||
|
|
||||||
return currentTxIsLatestWithNonce && Date.now() - submittedTime > 30000
|
return currentTxIsLatestWithNonce && Date.now() - submittedTime > 30000 && currentTxIsLatest
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionListItem.prototype.render = function () {
|
TransactionListItem.prototype.render = function () {
|
||||||
|
@ -213,14 +213,23 @@ TxListItem.prototype.showRetryButton = function () {
|
|||||||
if (!txParams) {
|
if (!txParams) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
let currentTxIsLatest = false
|
||||||
const currentNonce = txParams.nonce
|
const currentNonce = txParams.nonce
|
||||||
const currentNonceTxs = selectedAddressTxList.filter(tx => tx.txParams.nonce === currentNonce)
|
const currentNonceTxs = selectedAddressTxList.filter(tx => tx.txParams.nonce === currentNonce)
|
||||||
const currentNonceSubmittedTxs = currentNonceTxs.filter(tx => tx.status === 'submitted')
|
const currentNonceSubmittedTxs = currentNonceTxs.filter(tx => tx.status === 'submitted')
|
||||||
|
const currentSubmittedTxs = selectedAddressTxList.filter(tx => tx.status === 'submitted')
|
||||||
const lastSubmittedTxWithCurrentNonce = currentNonceSubmittedTxs[currentNonceSubmittedTxs.length - 1]
|
const lastSubmittedTxWithCurrentNonce = currentNonceSubmittedTxs[currentNonceSubmittedTxs.length - 1]
|
||||||
const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce &&
|
const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce &&
|
||||||
lastSubmittedTxWithCurrentNonce.id === transactionId
|
lastSubmittedTxWithCurrentNonce.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
|
return currentTxIsLatestWithNonce && Date.now() - transactionSubmittedTime > 30000 && currentTxIsLatest
|
||||||
}
|
}
|
||||||
|
|
||||||
TxListItem.prototype.setSelectedToken = function (tokenAddress) {
|
TxListItem.prototype.setSelectedToken = function (tokenAddress) {
|
||||||
|
Loading…
Reference in New Issue
Block a user