From 7a8a2c4913b93910356d414b1d7022030ce3178a Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Tue, 30 May 2017 19:56:48 -0400 Subject: [PATCH] connection changes and changelog --- CHANGELOG.md | 7 ++++-- ui/js/component/load_screen.js | 6 +++-- ui/js/component/splash.js | 22 +++++++++---------- ui/js/lbry.js | 40 +++++++++++++++------------------- ui/js/main.js | 2 +- 5 files changed, 39 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 163506d4f..fa4b0bbdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,14 +8,17 @@ Web UI version numbers should always match the corresponding version of LBRY App ## [Unreleased] ### Added - * + * * ### Changed - * + * Video player switched from plyr to render-media * ### Fixed + * Video player should behave better on streaming + * Daemon times out more quickly when it cannot start + * Connection should fail more cleanly, rather than get stuck entirely * Closing modal dialogs was broken on some download and stream errors * Discover landing page improperly showed loading error when it was loading correctly diff --git a/ui/js/component/load_screen.js b/ui/js/component/load_screen.js index 5b24e19b7..a07dda0c3 100644 --- a/ui/js/component/load_screen.js +++ b/ui/js/component/load_screen.js @@ -31,9 +31,11 @@ class LoadScreen extends React.Component { LBRY

- + {!this.props.isWarning ? + : + {' ' + this.props.message} }

- {this.props.isWarning ? : null} {this.props.details} + {this.props.details}
); diff --git a/ui/js/component/splash.js b/ui/js/component/splash.js index e2be56b67..98b09db93 100644 --- a/ui/js/component/splash.js +++ b/ui/js/component/splash.js @@ -13,6 +13,7 @@ export class SplashScreen extends React.Component { this.state = { details: 'Starting daemon', + message: "Connecting", isLagging: false, }; } @@ -29,11 +30,12 @@ export class SplashScreen extends React.Component { // 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', + message: "Testing Network", + details: "Waiting for name resolution", isLagging: false }); - lbry.resolve({uri: 'lbry://one'}).then(() => { + lbry.resolve({uri: "lbry://one"}).then(() => { this.props.onLoadDone(); }); return; @@ -48,21 +50,19 @@ export class SplashScreen extends React.Component { } componentDidMount() { - lbry.connect().then((isConnected) => { - if (isConnected) { - this.updateStatus(); - } else { + lbry.connect() + .then(() => { this.updateStatus() }) + .catch(() => { this.setState({ isLagging: true, - message: "Failed to connect to LBRY", - details: "LBRY was unable to start and connect properly." + message: "Connection Failure", + details: "Try closing all LBRY processes and starting again. If this still happpens, your anti-virus software or firewall may be preventing LBRY from connecting. Contact hello@lbry.io if you think this is a software bug." }) - } - }) + }) } render() { - return + return } } diff --git a/ui/js/lbry.js b/ui/js/lbry.js index b9230ce16..db9a1ae2a 100644 --- a/ui/js/lbry.js +++ b/ui/js/lbry.js @@ -95,26 +95,27 @@ lbry.call = function (method, params, callback, errorCallback, connectFailedCall lbry._connectPromise = null; lbry.connect = function() { if (lbry._connectPromise === null) { - lbry._connectPromise = new Promise((resolve, reject) => { + let tryNum = 0 + + function checkDaemonStartedFailed() { + console.log('status error try num ' + tryNum) + if (tryNum <= 100) { // Move # of tries into constant or config option + setTimeout(() => { + tryNum++ + checkDaemonStarted(); + }, tryNum < 50 ? 400 : 1000); + } + else { + reject(new Error("Unable to connect to LBRY")); + } + } + // Check every half second to see if the daemon is accepting connections - function checkDaemonStarted(tryNum = 0) { - lbry.isDaemonAcceptingConnections(function (runningStatus) { - if (runningStatus) { - resolve(true); - } - else { - if (tryNum <= 600) { // Move # of tries into constant or config option - setTimeout(function () { - checkDaemonStarted(tryNum + 1); - }, tryNum < 100 ? 200 : 1000); - } - else { - reject(new Error("Unable to connect to LBRY")); - } - } - }); + function checkDaemonStarted() { + console.log('check daemon started try ' + tryNum) + lbry.call('status', {}, resolve, checkDaemonStartedFailed, checkDaemonStartedFailed) } checkDaemonStarted(); @@ -124,11 +125,6 @@ lbry.connect = function() { return lbry._connectPromise; } -lbry.isDaemonAcceptingConnections = function (callback) { - // Returns true/false whether the daemon is at a point it will start returning status - lbry.call('status', {}, () => callback(true), null, () => callback(false)) -}; - lbry.checkAddressIsMine = function(address, callback) { lbry.call('address_is_mine', {address: address}, callback); } diff --git a/ui/js/main.js b/ui/js/main.js index 969ecfdc0..980bfe17c 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -89,7 +89,7 @@ var init = function() { if (window.sessionStorage.getItem('loaded') == 'y') { onDaemonReady(); } else { - ReactDOM.render(, canvas); + ReactDOM.render(, canvas); } };