Fix loading a tab while another one is initializing the worker
This commit is contained in:
parent
1d63419df8
commit
c59d744d78
@ -1554,7 +1554,7 @@ define([
|
|||||||
var hash = data.userHash || data.anonHash || Hash.createRandomHash('drive');
|
var hash = data.userHash || data.anonHash || Hash.createRandomHash('drive');
|
||||||
storeHash = hash;
|
storeHash = hash;
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
throw new Error('[Store.init] Unable to find or create a drive hash. Aborting...');
|
return void cb({error: '[Store.init] Unable to find or create a drive hash. Aborting...'});
|
||||||
}
|
}
|
||||||
// No password for drive
|
// No password for drive
|
||||||
var secret = Hash.getSecrets('drive', hash);
|
var secret = Hash.getSecrets('drive', hash);
|
||||||
@ -1660,12 +1660,26 @@ define([
|
|||||||
* - requestLogin
|
* - requestLogin
|
||||||
*/
|
*/
|
||||||
var initialized = false;
|
var initialized = false;
|
||||||
Store.init = function (clientId, data, callback) {
|
|
||||||
|
var whenReady = function (cb, i) {
|
||||||
|
if (store.returned) { return void cb(); }
|
||||||
|
if (i === 600) { return void cb(true); }
|
||||||
|
i = i || 0;
|
||||||
|
setTimeout(function() {
|
||||||
|
whenReady(cb, ++i);
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
Store.init = function (clientId, data, _callback) {
|
||||||
|
var callback = Util.once(_callback);
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
return void callback({
|
return void whenReady(function (isTo) {
|
||||||
|
if (isTo) { return void callback({error: 'TIMEOUT'}); }
|
||||||
|
callback({
|
||||||
state: 'ALREADY_INIT',
|
state: 'ALREADY_INIT',
|
||||||
returned: store.returned
|
returned: store.returned
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
initialized = true;
|
initialized = true;
|
||||||
postMessage = function (clientId, cmd, d, cb) {
|
postMessage = function (clientId, cmd, d, cb) {
|
||||||
@ -1680,7 +1694,11 @@ define([
|
|||||||
if (Object.keys(store.proxy).length === 1) {
|
if (Object.keys(store.proxy).length === 1) {
|
||||||
Feedback.send("FIRST_APP_USE", true);
|
Feedback.send("FIRST_APP_USE", true);
|
||||||
}
|
}
|
||||||
|
if (ret && ret.error) {
|
||||||
|
initialized = false;
|
||||||
|
} else {
|
||||||
store.returned = ret;
|
store.returned = ret;
|
||||||
|
}
|
||||||
|
|
||||||
callback(ret);
|
callback(ret);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user