Implement lbry.connect(); loading screen now actually checks if the daemon is loaded
This commit is contained in:
parent
74636bad63
commit
b2bcf3a436
1 changed files with 18 additions and 5 deletions
23
js/lbry.js
23
js/lbry.js
|
@ -31,11 +31,24 @@ lbry.call = function (method, params, callback)
|
||||||
//core
|
//core
|
||||||
lbry.connect = function(callback)
|
lbry.connect = function(callback)
|
||||||
{
|
{
|
||||||
//dummy connect function - one of the first things we should do is dump people to get help if it can't connect
|
// Check every half second to see if the daemon's running.
|
||||||
setTimeout(function() {
|
// Returns true to callback once connected, or false if it takes too long and we give up.
|
||||||
lbry.isConnected = true;
|
var try_num = 0;
|
||||||
callback();
|
var check_connected = setInterval(function() {
|
||||||
}, 1500);
|
lbry.call('is_running', {}, function(is_running) {
|
||||||
|
if (is_running) {
|
||||||
|
lbry.isConnected = true;
|
||||||
|
clearInterval(check_connected);
|
||||||
|
callback(true);
|
||||||
|
} else {
|
||||||
|
if (try_num >= 20) { // Move this into a constant or config option
|
||||||
|
clearInterval(check_connected);
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
try_num++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getBalance = function(callback)
|
lbry.getBalance = function(callback)
|
||||||
|
|
Loading…
Reference in a new issue