|
|
@ -7,11 +7,13 @@ import { batchChannel } from '../utils' |
|
|
|
router.when('/addresses/:addressHash').then(({ addressHash, blockNumber, filter }) => { |
|
|
|
router.when('/addresses/:addressHash').then(({ addressHash, blockNumber, filter }) => { |
|
|
|
const channel = socket.channel(`addresses:${addressHash}`, {}) |
|
|
|
const channel = socket.channel(`addresses:${addressHash}`, {}) |
|
|
|
const $channelDisconnected = $('[data-selector="channel-disconnected-message"]') |
|
|
|
const $channelDisconnected = $('[data-selector="channel-disconnected-message"]') |
|
|
|
|
|
|
|
const $channelBatching = $('[data-selector="channel-batching-message"]') |
|
|
|
channel.join() |
|
|
|
channel.join() |
|
|
|
.receive('ok', resp => { console.log('Joined successfully', `addresses:${addressHash}`, resp) }) |
|
|
|
.receive('ok', resp => { console.log('Joined successfully', `addresses:${addressHash}`, resp) }) |
|
|
|
.receive('error', resp => { console.log('Unable to join', `addresses:${addressHash}`, resp) }) |
|
|
|
.receive('error', resp => { console.log('Unable to join', `addresses:${addressHash}`, resp) }) |
|
|
|
channel.onError(() => { |
|
|
|
channel.onError(() => { |
|
|
|
$channelDisconnected.show() |
|
|
|
$channelDisconnected.show() |
|
|
|
|
|
|
|
$channelBatching.hide() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
if (!blockNumber) { |
|
|
|
if (!blockNumber) { |
|
|
@ -23,12 +25,21 @@ router.when('/addresses/:addressHash').then(({ addressHash, blockNumber, filter |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const $transactionsList = $('[data-selector="transactions-list"]') |
|
|
|
const $transactionsList = $('[data-selector="transactions-list"]') |
|
|
|
|
|
|
|
const $channelBatchingCount = $('[data-selector="channel-batching-count"]') |
|
|
|
|
|
|
|
let batchCountAccumulator = 0 |
|
|
|
if ($transactionsList.length) { |
|
|
|
if ($transactionsList.length) { |
|
|
|
channel.on('transaction', batchChannel((msgs) => { |
|
|
|
channel.on('transaction', batchChannel((msgs) => { |
|
|
|
if ($channelDisconnected.is(':visible')) { |
|
|
|
if ($channelDisconnected.is(':visible')) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msgs.length > 10 || batchCountAccumulator > 0) { |
|
|
|
|
|
|
|
$channelBatching.show() |
|
|
|
|
|
|
|
batchCountAccumulator += msgs.length |
|
|
|
|
|
|
|
$channelBatchingCount[0].innerHTML = batchCountAccumulator |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
msgs = humps.camelizeKeys(msgs) |
|
|
|
msgs = humps.camelizeKeys(msgs) |
|
|
|
|
|
|
|
|
|
|
|
if (filter === 'to') { |
|
|
|
if (filter === 'to') { |
|
|
|