2016-11-22 14:19:08 -06:00
|
|
|
import React from 'react';
|
|
|
|
import lbry from '../lbry.js';
|
|
|
|
import LoadScreen from './load_screen.js';
|
|
|
|
|
2016-04-09 20:00:56 -04:00
|
|
|
var SplashScreen = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
message: React.PropTypes.string,
|
2016-04-14 01:49:00 -04:00
|
|
|
onLoadDone: React.PropTypes.func,
|
|
|
|
},
|
2016-04-14 04:21:36 -04:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2016-04-15 06:41:01 -04:00
|
|
|
details: 'Starting daemon',
|
|
|
|
isLagging: false,
|
2016-04-14 04:21:36 -04:00
|
|
|
}
|
|
|
|
},
|
2016-04-17 21:32:45 -04:00
|
|
|
updateStatus: function(was_lagging=false) {
|
2017-01-18 09:29:47 -06:00
|
|
|
lbry.getDaemonStatus(this._updateStatusCallback);
|
|
|
|
},
|
|
|
|
_updateStatusCallback: function(status) {
|
|
|
|
if (status.code == 'started') {
|
|
|
|
// Wait until we are able to resolve a name before declaring
|
|
|
|
// that we are done.
|
|
|
|
// TODO: This is a hack, and the logic should live in the daemon
|
|
|
|
// to give us a better sense of when we are actually started
|
|
|
|
this.setState({
|
|
|
|
details: 'Waiting for name resolution',
|
|
|
|
isLagging: false
|
|
|
|
});
|
2016-04-14 02:27:06 -04:00
|
|
|
|
2017-01-18 09:29:47 -06:00
|
|
|
lbry.resolveName('one', () => {
|
|
|
|
this.props.onLoadDone();
|
2016-04-14 02:27:06 -04:00
|
|
|
});
|
2017-01-18 09:29:47 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.setState({
|
|
|
|
details: status.message + (status.is_lagging ? '' : '...'),
|
|
|
|
isLagging: status.is_lagging,
|
|
|
|
});
|
|
|
|
setTimeout(() => {
|
|
|
|
this.updateStatus(status.is_lagging);
|
|
|
|
}, 500);
|
2016-04-14 02:27:06 -04:00
|
|
|
},
|
2016-04-14 01:49:00 -04:00
|
|
|
componentDidMount: function() {
|
2017-01-18 09:29:47 -06:00
|
|
|
lbry.connect((connected) => {
|
|
|
|
this.updateStatus();
|
|
|
|
});
|
2016-04-09 20:00:56 -04:00
|
|
|
},
|
|
|
|
render: function() {
|
2016-09-21 01:19:23 -04:00
|
|
|
return <LoadScreen message={this.props.message} details={this.state.details} isWarning={this.state.isLagging} />;
|
2016-04-09 20:00:56 -04:00
|
|
|
}
|
2016-11-22 14:19:08 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
export default SplashScreen;
|