|
|
@ -5,7 +5,7 @@ import numeral from 'numeral' |
|
|
|
import socket from '../socket' |
|
|
|
import socket from '../socket' |
|
|
|
import { updateAllAges } from '../lib/from_now' |
|
|
|
import { updateAllAges } from '../lib/from_now' |
|
|
|
import { exchangeRateChannel, formatUsdValue } from '../lib/currency' |
|
|
|
import { exchangeRateChannel, formatUsdValue } from '../lib/currency' |
|
|
|
import { batchChannel, initRedux, slideDownPrepend } from '../utils' |
|
|
|
import { batchChannel, buildFullBlockList, initRedux, skippedBlockListBuilder, slideDownPrepend } from '../utils' |
|
|
|
import { createMarketHistoryChart } from '../lib/market_history_chart' |
|
|
|
import { createMarketHistoryChart } from '../lib/market_history_chart' |
|
|
|
|
|
|
|
|
|
|
|
const BATCH_THRESHOLD = 10 |
|
|
|
const BATCH_THRESHOLD = 10 |
|
|
@ -28,9 +28,13 @@ export const initialState = { |
|
|
|
export function reducer (state = initialState, action) { |
|
|
|
export function reducer (state = initialState, action) { |
|
|
|
switch (action.type) { |
|
|
|
switch (action.type) { |
|
|
|
case 'PAGE_LOAD': { |
|
|
|
case 'PAGE_LOAD': { |
|
|
|
|
|
|
|
const fullBlockNumberList = buildFullBlockList(action.blockNumbers) |
|
|
|
|
|
|
|
const fullSkippedBlockNumberList = _.difference(fullBlockNumberList, action.blockNumbers) |
|
|
|
|
|
|
|
const blockNumbers = fullBlockNumberList.slice(0, 4) |
|
|
|
return Object.assign({}, state, { |
|
|
|
return Object.assign({}, state, { |
|
|
|
blockNumbers: action.blockNumbers, |
|
|
|
blockNumbers, |
|
|
|
transactionCount: numeral(action.transactionCount).value() |
|
|
|
transactionCount: numeral(action.transactionCount).value(), |
|
|
|
|
|
|
|
skippedBlockNumbers: _.intersection(fullSkippedBlockNumberList, blockNumbers) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
case 'RECEIVED_NEW_ADDRESS_COUNT': { |
|
|
|
case 'RECEIVED_NEW_ADDRESS_COUNT': { |
|
|
@ -52,21 +56,18 @@ export function reducer (state = initialState, action) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
let skippedBlockNumbers = state.skippedBlockNumbers.slice(0) |
|
|
|
let skippedBlockNumbers = state.skippedBlockNumbers.slice(0) |
|
|
|
if (blockNumber > state.blockNumbers[0] + 1) { |
|
|
|
if (blockNumber > state.blockNumbers[0] + 1) { |
|
|
|
let lastPlaceholder = state.blockNumbers[0] + 1 |
|
|
|
let oldestBlock = state.blockNumbers[0] |
|
|
|
if (blockNumber - lastPlaceholder > 3) { |
|
|
|
if (blockNumber - oldestBlock >= 3) { |
|
|
|
lastPlaceholder = blockNumber - 3 |
|
|
|
|
|
|
|
skippedBlockNumbers = [] |
|
|
|
skippedBlockNumbers = [] |
|
|
|
|
|
|
|
if (blockNumber - oldestBlock > 3) oldestBlock = blockNumber - 4 |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = lastPlaceholder; i < blockNumber; i++) { |
|
|
|
skippedBlockListBuilder(skippedBlockNumbers, blockNumber, oldestBlock) |
|
|
|
skippedBlockNumbers.push(i) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
const newBlockNumbers = _.chain([blockNumber]) |
|
|
|
const newBlockNumbers = _.chain([blockNumber]) |
|
|
|
.union(skippedBlockNumbers, state.blockNumbers) |
|
|
|
.union(skippedBlockNumbers, state.blockNumbers) |
|
|
|
.orderBy([], ['desc']) |
|
|
|
.orderBy([], ['desc']) |
|
|
|
.slice(0, 4) |
|
|
|
.slice(0, 4) |
|
|
|
.value() |
|
|
|
.value() |
|
|
|
|
|
|
|
|
|
|
|
const newSkippedBlockNumbers = _.intersection(skippedBlockNumbers, newBlockNumbers) |
|
|
|
const newSkippedBlockNumbers = _.intersection(skippedBlockNumbers, newBlockNumbers) |
|
|
|
return Object.assign({}, state, { |
|
|
|
return Object.assign({}, state, { |
|
|
|
averageBlockTime: action.msg.averageBlockTime, |
|
|
|
averageBlockTime: action.msg.averageBlockTime, |
|
|
@ -142,6 +143,8 @@ if ($chainDetailsPage.length) { |
|
|
|
const $marketCap = $('[data-selector="market-cap"]') |
|
|
|
const $marketCap = $('[data-selector="market-cap"]') |
|
|
|
const $transactionsList = $('[data-selector="transactions-list"]') |
|
|
|
const $transactionsList = $('[data-selector="transactions-list"]') |
|
|
|
const $transactionCount = $('[data-selector="transaction-count"]') |
|
|
|
const $transactionCount = $('[data-selector="transaction-count"]') |
|
|
|
|
|
|
|
const newTransactions = _.difference(state.newTransactions, oldState.newTransactions) |
|
|
|
|
|
|
|
const skippedBlockNumbers = _.difference(state.skippedBlockNumbers, oldState.skippedBlockNumbers) |
|
|
|
|
|
|
|
|
|
|
|
if (oldState.addressCount !== state.addressCount) { |
|
|
|
if (oldState.addressCount !== state.addressCount) { |
|
|
|
$addressCount.empty().append(state.addressCount) |
|
|
|
$addressCount.empty().append(state.addressCount) |
|
|
@ -152,24 +155,23 @@ if ($chainDetailsPage.length) { |
|
|
|
if (oldState.usdMarketCap !== state.usdMarketCap) { |
|
|
|
if (oldState.usdMarketCap !== state.usdMarketCap) { |
|
|
|
$marketCap.empty().append(formatUsdValue(state.usdMarketCap)) |
|
|
|
$marketCap.empty().append(formatUsdValue(state.usdMarketCap)) |
|
|
|
} |
|
|
|
} |
|
|
|
if (state.newBlock && oldState.newBlock !== state.newBlock) { |
|
|
|
if ((state.newBlock && oldState.newBlock !== state.newBlock) || skippedBlockNumbers.length) { |
|
|
|
if (state.replaceBlock && oldState.replaceBlock !== state.replaceBlock) { |
|
|
|
if (state.replaceBlock && oldState.replaceBlock !== state.replaceBlock) { |
|
|
|
const $replaceBlock = $(`[data-block-number="${state.replaceBlock}"]`) |
|
|
|
const $replaceBlock = $(`[data-block-number="${state.replaceBlock}"]`) |
|
|
|
$replaceBlock.addClass('shrink-out') |
|
|
|
$replaceBlock.addClass('shrink-out') |
|
|
|
setTimeout(() => $replaceBlock.replaceWith(state.newBlock), 400) |
|
|
|
setTimeout(() => $replaceBlock.replaceWith(state.newBlock), 400) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (oldState.skippedBlockNumbers !== state.skippedBlockNumbers) { |
|
|
|
if (state.newBlock) { |
|
|
|
const newSkippedBlockNumbers = _.chain(state.skippedBlockNumbers) |
|
|
|
$blockList.children().last().remove() |
|
|
|
.difference(oldState.skippedBlockNumbers) |
|
|
|
$blockList.prepend(newBlockHtml(state.newBlock)) |
|
|
|
.intersection(state.blockNumbers) |
|
|
|
} |
|
|
|
.value() |
|
|
|
if (skippedBlockNumbers.length) { |
|
|
|
_.map(newSkippedBlockNumbers, (skippedBlockNumber) => { |
|
|
|
const newSkippedBlockNumbers = _.intersection(skippedBlockNumbers, state.blockNumbers) |
|
|
|
|
|
|
|
_.each(newSkippedBlockNumbers, (skippedBlockNumber) => { |
|
|
|
$blockList.children().last().remove() |
|
|
|
$blockList.children().last().remove() |
|
|
|
$blockList.prepend(placeHolderBlock(skippedBlockNumber)) |
|
|
|
$(`[data-block-number="${skippedBlockNumber + 1}"]`).parent().after(placeHolderBlock(skippedBlockNumber)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
$blockList.children().last().remove() |
|
|
|
|
|
|
|
$blockList.prepend(newBlockHtml(state.newBlock)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
updateAllAges() |
|
|
|
updateAllAges() |
|
|
|
} |
|
|
|
} |
|
|
@ -180,7 +182,7 @@ if ($chainDetailsPage.length) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$channelBatching.hide() |
|
|
|
$channelBatching.hide() |
|
|
|
} |
|
|
|
} |
|
|
|
if (oldState.newTransactions !== state.newTransactions) { |
|
|
|
if (newTransactions.length) { |
|
|
|
const newTransactionsToInsert = state.newTransactions.slice(oldState.newTransactions.length) |
|
|
|
const newTransactionsToInsert = state.newTransactions.slice(oldState.newTransactions.length) |
|
|
|
$transactionsList |
|
|
|
$transactionsList |
|
|
|
.children() |
|
|
|
.children() |
|
|
@ -190,7 +192,6 @@ if ($chainDetailsPage.length) { |
|
|
|
|
|
|
|
|
|
|
|
updateAllAges() |
|
|
|
updateAllAges() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (oldState.availableSupply !== state.availableSupply || oldState.marketHistoryData !== state.marketHistoryData) { |
|
|
|
if (oldState.availableSupply !== state.availableSupply || oldState.marketHistoryData !== state.marketHistoryData) { |
|
|
|
chart.update(state.availableSupply, state.marketHistoryData) |
|
|
|
chart.update(state.availableSupply, state.marketHistoryData) |
|
|
|
} |
|
|
|
} |
|
|
@ -214,9 +215,9 @@ function placeHolderBlock (blockNumber) { |
|
|
|
> |
|
|
|
> |
|
|
|
<div |
|
|
|
<div |
|
|
|
class="tile tile-type-block d-flex align-items-center fade-up" |
|
|
|
class="tile tile-type-block d-flex align-items-center fade-up" |
|
|
|
|
|
|
|
style="height: 100px;" |
|
|
|
data-selector="place-holder" |
|
|
|
data-selector="place-holder" |
|
|
|
data-block-number="${blockNumber}" |
|
|
|
data-block-number="${blockNumber}" |
|
|
|
style="height: 100px;" |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<span class="loading-spinner-small ml-1 mr-4"> |
|
|
|
<span class="loading-spinner-small ml-1 mr-4"> |
|
|
|
<span class="loading-spinner-block-1"></span> |
|
|
|
<span class="loading-spinner-block-1"></span> |
|
|
|