Merge pull request #2932 from poanetwork/fix-websockets-connection

Fix duplicate websocket connection
pull/2933/head
Victor Baranov 5 years ago committed by GitHub
commit 140990002c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 6
      apps/block_scout_web/assets/js/lib/currency.js
  3. 15
      apps/block_scout_web/assets/js/pages/chain.js

@ -10,6 +10,8 @@
- [#2902](https://github.com/poanetwork/blockscout/pull/2902) - Offset in blocks retrieval for average block time - [#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 - [#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 - [#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 ### Chore
- [#2896](https://github.com/poanetwork/blockscout/pull/2896) - Disable Parity websockets tests - [#2896](https://github.com/poanetwork/blockscout/pull/2896) - Disable Parity websockets tests

@ -1,8 +1,6 @@
import $ from 'jquery' import $ from 'jquery'
import humps from 'humps'
import numeral from 'numeral' import numeral from 'numeral'
import { BigNumber } from 'bignumber.js' import { BigNumber } from 'bignumber.js'
import socket from '../socket'
export function formatUsdValue (value) { export function formatUsdValue (value) {
return `${formatCurrencyValue(value)} USD` return `${formatCurrencyValue(value)} USD`
@ -63,7 +61,3 @@ export function updateAllCalculatedUsdValues (usdExchangeRate) {
$('[data-usd-unit-price]').each((i, el) => tryUpdateUnitPriceValues(el, usdExchangeRate)) $('[data-usd-unit-price]').each((i, el) => tryUpdateUnitPriceValues(el, usdExchangeRate))
} }
updateAllCalculatedUsdValues() updateAllCalculatedUsdValues()
export const exchangeRateChannel = socket.channel('exchange_rate:new_rate')
exchangeRateChannel.join()
exchangeRateChannel.on('new_rate', (msg) => updateAllCalculatedUsdValues(humps.camelizeKeys(msg).exchangeRate.usdValue))

@ -7,7 +7,7 @@ import map from 'lodash/map'
import humps from 'humps' import humps from 'humps'
import numeral from 'numeral' import numeral from 'numeral'
import socket from '../socket' 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 { createStore, connectElements } from '../lib/redux_helpers.js'
import { batchChannel, showLoader } from '../lib/utils' import { batchChannel, showLoader } from '../lib/utils'
import listMorph from '../lib/list_morph' import listMorph from '../lib/list_morph'
@ -258,10 +258,15 @@ if ($chainDetailsPage.length) {
loadBlocks(store) loadBlocks(store)
bindBlockErrorMessage(store) bindBlockErrorMessage(store)
exchangeRateChannel.on('new_rate', (msg) => store.dispatch({ const exchangeRateChannel = socket.channel('exchange_rate:new_rate')
type: 'RECEIVED_NEW_EXCHANGE_RATE', exchangeRateChannel.join()
msg: humps.camelizeKeys(msg) 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') const addressesChannel = socket.channel('addresses:new_address')
addressesChannel.join() addressesChannel.join()

Loading…
Cancel
Save