From 71777e0e9a0ce5ca125f566e50e82135d0310dd7 Mon Sep 17 00:00:00 2001 From: jimmay5469 Date: Mon, 15 Oct 2018 15:46:24 -0400 Subject: [PATCH] Update number of pending transactions --- apps/block_scout_web/assets/js/pages/address.js | 10 +++++++++- apps/block_scout_web/assets/js/utils.js | 6 +++--- .../templates/address_transaction/index.html.eex | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/block_scout_web/assets/js/pages/address.js b/apps/block_scout_web/assets/js/pages/address.js index 5be64da4a4..feb588cc8b 100644 --- a/apps/block_scout_web/assets/js/pages/address.js +++ b/apps/block_scout_web/assets/js/pages/address.js @@ -106,6 +106,10 @@ export function reducer (state = initialState, action) { newPendingTransactions: [ ...state.newPendingTransactions, action.msg.transactionHtml + ], + pendingTransactionHashes: [ + ...state.pendingTransactionHashes, + action.msg.transactionHash ] }) } @@ -155,7 +159,7 @@ if ($addressDetailsPage.length) { addressHash, beyondPageOne: !!blockNumber, filter, - pendingTransactionHashes: $('[data-selector="pending-transactions-list"]') + pendingTransactionHashes: $('[data-selector="pending-transactions-list"]').children() .map((index, el) => el.dataset.transactionHash).toArray(), transactionCount: $('[data-selector="transaction-count"]').text(), validationCount: $('[data-selector="validation-count"]') ? $('[data-selector="validation-count"]').text() : null @@ -183,6 +187,7 @@ if ($addressDetailsPage.length) { const $emptyInternalTransactionsList = $('[data-selector="empty-internal-transactions-list"]') const $emptyTransactionsList = $('[data-selector="empty-transactions-list"]') const $internalTransactionsList = $('[data-selector="internal-transactions-list"]') + const $pendingTransactionsCount = $('[data-selector="pending-transactions-count"]') const $pendingTransactionsList = $('[data-selector="pending-transactions-list"]') const $transactionCount = $('[data-selector="transaction-count"]') const $transactionsList = $('[data-selector="transactions-list"]') @@ -214,6 +219,9 @@ if ($addressDetailsPage.length) { prependWithClingBottom($internalTransactionsList, state.newInternalTransactions.slice(oldState.newInternalTransactions.length).reverse().join('')) updateAllAges() } + if (oldState.pendingTransactionHashes.length !== state.pendingTransactionHashes.length && $pendingTransactionsCount.length) { + $pendingTransactionsCount[0].innerHTML = numeral(state.pendingTransactionHashes.length).format() + } if (oldState.newPendingTransactions !== state.newPendingTransactions && $pendingTransactionsList.length) { prependWithClingBottom($pendingTransactionsList, state.newPendingTransactions.slice(oldState.newPendingTransactions.length).reverse().join('')) updateAllAges() diff --git a/apps/block_scout_web/assets/js/utils.js b/apps/block_scout_web/assets/js/utils.js index 6544debd3c..6e633b7613 100644 --- a/apps/block_scout_web/assets/js/utils.js +++ b/apps/block_scout_web/assets/js/utils.js @@ -56,13 +56,13 @@ export function slideDownBefore ($el, content, callback) { $content.slideDown({ complete: callback }) } export function prependWithClingBottom ($el, content) { - return slideDownPrepend($el, content, clingBottom($el, content)) + return slideDownPrepend($el, content, clingBottom($el)) } export function beforeWithClingBottom ($el, content) { - return slideDownBefore($el, content, clingBottom($el, content)) + return slideDownBefore($el, content, clingBottom($el)) } -function clingBottom ($el, content) { +function clingBottom ($el) { function userAtTop () { return window.scrollY < $('[data-selector="navbar"]').outerHeight() } diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_transaction/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_transaction/index.html.eex index d313d84cab..8f74aca73b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_transaction/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_transaction/index.html.eex @@ -52,11 +52,11 @@

<%= gettext "Transactions" %>

+ <%= length(@pending_transactions) %> + <%= gettext("Pending Transactions") %> <%= link to: "#pending-transactions", "data-toggle": "collapse" do %> <%= gettext("Show") %> <%= gettext("Hide") %> - <%= length(@pending_transactions) %> - <%= gettext("Pending Transactions") %> <% end %>
<%= for pending_transaction <- @pending_transactions do %>