Co-authored-by: Stamates <stamates@hotmail.com>
pull/916/head
jimmay5469 6 years ago committed by Stamates
parent 1814f3ee76
commit 88ab1172bc
  1. 4
      apps/block_scout_web/assets/js/lib/currency.js
  2. 16
      apps/block_scout_web/assets/js/lib/indexing.js

@ -34,10 +34,8 @@ function tryUpdateCalculatedUsdValues (el, usdExchangeRate = el.dataset.usdExcha
const formattedUsd = formatUsdValue(usd)
if (formattedUsd !== el.innerHTML) el.innerHTML = formattedUsd
}
let currentUsdExchangeRate
export function updateAllCalculatedUsdValues (usdExchangeRate) {
currentUsdExchangeRate = usdExchangeRate
$('[data-usd-exchange-rate]').each((i, el) => tryUpdateCalculatedUsdValues(el, currentUsdExchangeRate))
$('[data-usd-exchange-rate]').each((i, el) => tryUpdateCalculatedUsdValues(el, usdExchangeRate))
}
updateAllCalculatedUsdValues()

@ -1,29 +1,25 @@
import $ from 'jquery'
import _ from 'lodash'
import humps from 'humps'
import numeral from 'numeral'
import socket from '../socket'
function tryUpdateIndexedStatus (el, indexedRatio = el.dataset.indexedRatio, indexingFinished = false) {
if (indexingFinished) return $("[data-selector='indexed-status']").remove()
const blocksPercentComplete = numeral(indexedRatio).format('0%')
let indexedText
if (parseInt(indexedRatio) === 1.0) {
if (blocksPercentComplete === '100%') {
indexedText = window.localized['Indexing Tokens']
} else {
indexedText = `${numeral(indexedRatio).format('0%')} ${window.localized['Blocks Indexed']}`
indexedText = `${blocksPercentComplete} ${window.localized['Blocks Indexed']}`
}
if (indexedText !== el.innerHTML) el.innerHTML = indexedText
}
let currentIndexedRatio
let indexingFinished
export function updateIndexStatus (msg) {
currentIndexedRatio = _.get(msg, 'ratio')
indexingFinished = _.get(msg, 'finished')
$('[data-indexed-ratio]').each((i, el) => tryUpdateIndexedStatus(el, currentIndexedRatio, indexingFinished))
export function updateIndexStatus (msg = {}) {
$('[data-indexed-ratio]').each((i, el) => tryUpdateIndexedStatus(el, msg.ratio, msg.finished))
}
updateIndexStatus()
export const indexingChannel = socket.channel(`blocks:indexing`)
const indexingChannel = socket.channel(`blocks:indexing`)
indexingChannel.join()
indexingChannel.on('index_status', (msg) => updateIndexStatus(humps.camelizeKeys(msg)))

Loading…
Cancel
Save