diff --git a/CHANGELOG.md b/CHANGELOG.md index 67d0f340c7..adea69b2cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ - [#2902](https://github.com/poanetwork/blockscout/pull/2902) - Offset in blocks retrieval for average block time - [#2900](https://github.com/poanetwork/blockscout/pull/2900) - check fetched instance metadata in multiple places - [#2899](https://github.com/poanetwork/blockscout/pull/2899) - fix empty buffered task +- [#2887](https://github.com/poanetwork/blockscout/pull/2887) - increase chart loading speed +- [#2932](https://github.com/poanetwork/blockscout/pull/2932) - fix duplicate websocket connection ### Chore - [#2896](https://github.com/poanetwork/blockscout/pull/2896) - Disable Parity websockets tests diff --git a/apps/block_scout_web/assets/js/lib/currency.js b/apps/block_scout_web/assets/js/lib/currency.js index 6d3022625f..ddb550252a 100644 --- a/apps/block_scout_web/assets/js/lib/currency.js +++ b/apps/block_scout_web/assets/js/lib/currency.js @@ -1,8 +1,6 @@ import $ from 'jquery' -import humps from 'humps' import numeral from 'numeral' import { BigNumber } from 'bignumber.js' -import socket from '../socket' export function formatUsdValue (value) { return `${formatCurrencyValue(value)} USD` @@ -63,7 +61,3 @@ export function updateAllCalculatedUsdValues (usdExchangeRate) { $('[data-usd-unit-price]').each((i, el) => tryUpdateUnitPriceValues(el, usdExchangeRate)) } updateAllCalculatedUsdValues() - -export const exchangeRateChannel = socket.channel('exchange_rate:new_rate') -exchangeRateChannel.join() -exchangeRateChannel.on('new_rate', (msg) => updateAllCalculatedUsdValues(humps.camelizeKeys(msg).exchangeRate.usdValue)) diff --git a/apps/block_scout_web/assets/js/pages/chain.js b/apps/block_scout_web/assets/js/pages/chain.js index 405dc68db7..0421558e1c 100644 --- a/apps/block_scout_web/assets/js/pages/chain.js +++ b/apps/block_scout_web/assets/js/pages/chain.js @@ -7,7 +7,7 @@ import map from 'lodash/map' import humps from 'humps' import numeral from 'numeral' import socket from '../socket' -import { exchangeRateChannel, formatUsdValue } from '../lib/currency' +import { updateAllCalculatedUsdValues, formatUsdValue } from '../lib/currency' import { createStore, connectElements } from '../lib/redux_helpers.js' import { batchChannel, showLoader } from '../lib/utils' import listMorph from '../lib/list_morph' @@ -258,10 +258,15 @@ if ($chainDetailsPage.length) { loadBlocks(store) bindBlockErrorMessage(store) - exchangeRateChannel.on('new_rate', (msg) => store.dispatch({ - type: 'RECEIVED_NEW_EXCHANGE_RATE', - msg: humps.camelizeKeys(msg) - })) + const exchangeRateChannel = socket.channel('exchange_rate:new_rate') + exchangeRateChannel.join() + exchangeRateChannel.on('new_rate', (msg) => { + updateAllCalculatedUsdValues(humps.camelizeKeys(msg).exchangeRate.usdValue) + store.dispatch({ + type: 'RECEIVED_NEW_EXCHANGE_RATE', + msg: humps.camelizeKeys(msg) + }) + }) const addressesChannel = socket.channel('addresses:new_address') addressesChannel.join()