mirror of https://github.com/embarklabs/embark.git
add a warning if not enough blocks or no blocks
This commit is contained in:
parent
fc902b6242
commit
dbe12c6fb9
|
@ -4,7 +4,7 @@ import React from "react";
|
||||||
import Loading from '../components/Loading';
|
import Loading from '../components/Loading';
|
||||||
import Error from '../components/Error';
|
import Error from '../components/Error';
|
||||||
|
|
||||||
const DataWrapper = ({error, loading, shouldRender, render, ...rest}) => {
|
const DataWrapper = ({error, loading, shouldRender, render, elseRender, ...rest}) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
return <Error error={error} />;
|
return <Error error={error} />;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,10 @@ const DataWrapper = ({error, loading, shouldRender, render, ...rest}) => {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elseRender) {
|
||||||
|
return elseRender(rest);
|
||||||
|
}
|
||||||
|
|
||||||
return <React.Fragment />;
|
return <React.Fragment />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,6 +28,7 @@ DataWrapper.propTypes = {
|
||||||
error: PropTypes.string,
|
error: PropTypes.string,
|
||||||
loading: PropTypes.bool,
|
loading: PropTypes.bool,
|
||||||
render: PropTypes.func,
|
render: PropTypes.func,
|
||||||
|
elseRender: PropTypes.func,
|
||||||
shouldRender: PropTypes.bool
|
shouldRender: PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import GasStation from '../components/GasStation';
|
||||||
import {stopGasOracle, listenToGasOracle, gasOracle as ethGasAction, blocks as blocksAction} from "../actions";
|
import {stopGasOracle, listenToGasOracle, gasOracle as ethGasAction, blocks as blocksAction} from "../actions";
|
||||||
import DataWrapper from "../components/DataWrapper";
|
import DataWrapper from "../components/DataWrapper";
|
||||||
import {getOracleGasStats, getLastBlock} from "../reducers/selectors";
|
import {getOracleGasStats, getLastBlock} from "../reducers/selectors";
|
||||||
|
import {Alert} from 'reactstrap';
|
||||||
|
|
||||||
class GasStationContainer extends Component {
|
class GasStationContainer extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -18,6 +19,9 @@ class GasStationContainer extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentGas() {
|
getCurrentGas() {
|
||||||
|
if (!this.gasStation) {
|
||||||
|
return 'Unavailable';
|
||||||
|
}
|
||||||
return this.gasStation.getCurrentGas();
|
return this.gasStation.getCurrentGas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +29,13 @@ class GasStationContainer extends Component {
|
||||||
return <DataWrapper shouldRender={Boolean(this.props.gasOracleStats && Object.keys(this.props.gasOracleStats).length && this.props.lastBlock)}
|
return <DataWrapper shouldRender={Boolean(this.props.gasOracleStats && Object.keys(this.props.gasOracleStats).length && this.props.lastBlock)}
|
||||||
{...this.props} render={({lastBlock, gasOracleStats}) => (
|
{...this.props} render={({lastBlock, gasOracleStats}) => (
|
||||||
<GasStation gasOracleStats={gasOracleStats} lastBlock={lastBlock} ref={instance => { this.gasStation = instance; }}/>
|
<GasStation gasOracleStats={gasOracleStats} lastBlock={lastBlock} ref={instance => { this.gasStation = instance; }}/>
|
||||||
)}/>;
|
)} elseRender={() => {
|
||||||
|
let message = 'Currently not enough blocks mined to estimated';
|
||||||
|
if (Object.keys(this.props.gasOracleStats).length === 0) {
|
||||||
|
message = 'No blocks detected. If you are connected using an RPC connection, switch to WS to have access to new block events.'
|
||||||
|
}
|
||||||
|
return (<Alert color="danger">{message}</Alert>)
|
||||||
|
}}/>;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue