1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 03:36:18 +02:00

Merge pull request #4926 from MetaMask/update-logic-for-retry-button

Show the retry button on latest tx of earliest nonce.
This commit is contained in:
Dan J Miller 2018-08-01 00:04:27 -02:30 committed by GitHub
commit 6ccc34cb52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -36,7 +36,7 @@ TransactionListItem.prototype.showRetryButton = function () {
return false return false
} }
let currentTxIsLatest = false let currentTxSharesEarliestNonce = 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')
@ -45,14 +45,14 @@ TransactionListItem.prototype.showRetryButton = function () {
const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce && const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce &&
lastSubmittedTxWithCurrentNonce.id === transaction.id lastSubmittedTxWithCurrentNonce.id === transaction.id
if (currentSubmittedTxs.length > 0) { if (currentSubmittedTxs.length > 0) {
const lastTx = currentSubmittedTxs.reduce((tx1, tx2) => { const earliestSubmitted = currentSubmittedTxs.reduce((tx1, tx2) => {
if (tx1.submittedTime < tx2.submittedTime) return tx1 if (tx1.submittedTime < tx2.submittedTime) return tx1
return tx2 return tx2
}) })
currentTxIsLatest = lastTx.id === transaction.id currentTxSharesEarliestNonce = currentNonce === earliestSubmitted.txParams.nonce
} }
return currentTxIsLatestWithNonce && Date.now() - submittedTime > 30000 && currentTxIsLatest return currentTxSharesEarliestNonce && currentTxIsLatestWithNonce && Date.now() - submittedTime > 30000
} }
TransactionListItem.prototype.render = function () { TransactionListItem.prototype.render = function () {

View File

@ -213,7 +213,7 @@ TxListItem.prototype.showRetryButton = function () {
if (!txParams) { if (!txParams) {
return false return false
} }
let currentTxIsLatest = false let currentTxSharesEarliestNonce = 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')
@ -222,14 +222,14 @@ TxListItem.prototype.showRetryButton = function () {
const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce && const currentTxIsLatestWithNonce = lastSubmittedTxWithCurrentNonce &&
lastSubmittedTxWithCurrentNonce.id === transactionId lastSubmittedTxWithCurrentNonce.id === transactionId
if (currentSubmittedTxs.length > 0) { if (currentSubmittedTxs.length > 0) {
const lastTx = currentSubmittedTxs.reduce((tx1, tx2) => { const earliestSubmitted = currentSubmittedTxs.reduce((tx1, tx2) => {
if (tx1.submittedTime < tx2.submittedTime) return tx1 if (tx1.submittedTime < tx2.submittedTime) return tx1
return tx2 return tx2
}) })
currentTxIsLatest = lastTx.id === transactionId currentTxSharesEarliestNonce = currentNonce === earliestSubmitted.txParams.nonce
} }
return currentTxIsLatestWithNonce && Date.now() - transactionSubmittedTime > 30000 && currentTxIsLatest return currentTxSharesEarliestNonce && currentTxIsLatestWithNonce && Date.now() - transactionSubmittedTime > 30000
} }
TxListItem.prototype.setSelectedToken = function (tokenAddress) { TxListItem.prototype.setSelectedToken = function (tokenAddress) {