Feedback PR

This commit is contained in:
Anthony Laibe 2018-08-02 14:49:38 +01:00 committed by Pascal Precht
parent c043adf031
commit ede5afa6e0
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
3 changed files with 7 additions and 10 deletions

View File

@ -9,11 +9,6 @@ import LoadMore from '../components/LoadMore';
class BlocksContainer extends Component { class BlocksContainer extends Component {
constructor(props) {
super(props);
this.loadMore = this.loadMore.bind(this);
}
componentDidMount() { componentDidMount() {
if (!this.props.blocks.data) { if (!this.props.blocks.data) {
this.props.fetchBlocks(); this.props.fetchBlocks();
@ -46,7 +41,7 @@ class BlocksContainer extends Component {
return ( return (
<React.Fragment> <React.Fragment>
<Blocks blocks={blocks.data}/> <Blocks blocks={blocks.data}/>
{(this.loadMoreFrom() >= 0) ? <LoadMore loadMore={this.loadMore} /> : <React.Fragment />} {(this.loadMoreFrom() >= 0) ? <LoadMore loadMore={() => this.loadMore()} /> : <React.Fragment />}
</React.Fragment> </React.Fragment>
); );
} }

View File

@ -3,7 +3,7 @@ import {RECEIVE_BLOCKS, RECEIVE_BLOCKS_ERROR} from "../actions";
export default function blocks(state = {}, action) { export default function blocks(state = {}, action) {
switch (action.type) { switch (action.type) {
case RECEIVE_BLOCKS: case RECEIVE_BLOCKS:
return Object.assign({}, state, {data: [...state.data || [], ...action.blocks.data]}); return {...state, data: [...state.data || [], ...action.blocks.data]};
case RECEIVE_BLOCKS_ERROR: case RECEIVE_BLOCKS_ERROR:
return Object.assign({}, state, {error: true}); return Object.assign({}, state, {error: true});
default: default:

View File

@ -301,6 +301,7 @@ class BlockchainConnector {
function(callback) { function(callback) {
self.getTransactionCount(address, (err, count) => { self.getTransactionCount(address, (err, count) => {
if (err) { if (err) {
self.logger.error(err);
result.transactionCount = 0; result.transactionCount = 0;
} else { } else {
result.transactionCount = count; result.transactionCount = count;
@ -311,6 +312,7 @@ class BlockchainConnector {
function(callback) { function(callback) {
self.getBalance(address, (err, balance) => { self.getBalance(address, (err, balance) => {
if (err) { if (err) {
self.logger.error(err);
result.balance = 0; result.balance = 0;
} else { } else {
result.balance = self.web3.utils.fromWei(balance); result.balance = self.web3.utils.fromWei(balance);
@ -342,6 +344,7 @@ class BlockchainConnector {
} }
self.getBlockNumber((err, blockNumber) => { self.getBlockNumber((err, blockNumber) => {
if (err) { if (err) {
self.logger.error(err);
from = 0; from = 0;
} else { } else {
from = blockNumber; from = blockNumber;
@ -353,14 +356,13 @@ class BlockchainConnector {
async.times(limit, function(n, next) { async.times(limit, function(n, next) {
self.web3.eth.getBlock(from - n, function(err, block) { self.web3.eth.getBlock(from - n, function(err, block) {
if (err){ if (err){
self.logger.error(err);
return next(); return next();
} }
results.push(block); results.push(block);
next(); next();
}); });
}, function() { }, callback);
callback();
});
} }
], function () { ], function () {
res.send(results); res.send(results);