Fix workers submodules after reconnecting

pull/1/head
yflory 4 years ago
parent e629f0aa47
commit cebe1252f8

@ -1378,13 +1378,16 @@ define([
// Universal // Universal
Store.universal = { Store.universal = {
execCommand: function (clientId, obj, cb) { execCommand: function (clientId, obj, cb) {
onReadyEvt.reg(function () {
var type = obj.type; var type = obj.type;
var data = obj.data; var data = obj.data;
if (store.modules[type]) { if (store.modules[type]) {
console.error(obj);
store.modules[type].execCommand(clientId, data, cb); store.modules[type].execCommand(clientId, data, cb);
} else { } else {
return void cb({error: type + ' is disabled'}); return void cb({error: type + ' is disabled'});
} }
});
} }
}; };
var loadUniversal = function (Module, type, waitFor, clientId) { var loadUniversal = function (Module, type, waitFor, clientId) {
@ -1424,17 +1427,23 @@ define([
// Cursor // Cursor
Store.cursor = { Store.cursor = {
execCommand: function (clientId, data, cb) { execCommand: function (clientId, data, cb) {
// The cursor module can only be used when the store is ready
onReadyEvt.reg(function () {
if (!store.cursor) { return void cb ({error: 'Cursor channel is disabled'}); } if (!store.cursor) { return void cb ({error: 'Cursor channel is disabled'}); }
store.cursor.execCommand(clientId, data, cb); store.cursor.execCommand(clientId, data, cb);
});
} }
}; };
// Mailbox // Mailbox
Store.mailbox = { Store.mailbox = {
execCommand: function (clientId, data, cb) { execCommand: function (clientId, data, cb) {
// The mailbox can only be used when the store is ready
onReadyEvt.reg(function () {
if (!store.loggedIn) { return void cb(); } if (!store.loggedIn) { return void cb(); }
if (!store.mailbox) { return void cb ({error: 'Mailbox is disabled'}); } if (!store.mailbox) { return void cb ({error: 'Mailbox is disabled'}); }
store.mailbox.execCommand(clientId, data, cb); store.mailbox.execCommand(clientId, data, cb);
});
} }
}; };
@ -2664,9 +2673,9 @@ define([
broadcast([], "UPDATE_TOKEN", { token: proxy[Constants.tokenKey] }); broadcast([], "UPDATE_TOKEN", { token: proxy[Constants.tokenKey] });
}); });
onReadyEvt.fire();
loadMailbox(); loadMailbox();
onReadyEvt.fire();
}); });
}; };

@ -310,7 +310,6 @@ define([
onDisconnect(); onDisconnect();
}); });
sframeChan.on('EV_NETWORK_RECONNECT', function () { sframeChan.on('EV_NETWORK_RECONNECT', function () {
console.log('here');
onReconnect(); onReconnect();
}); });
common.onLogout(function () { setEditable(false); }); common.onLogout(function () { setEditable(false); });

Loading…
Cancel
Save