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) {
var type = obj.type; onReadyEvt.reg(function () {
var data = obj.data; var type = obj.type;
if (store.modules[type]) { var data = obj.data;
store.modules[type].execCommand(clientId, data, cb); if (store.modules[type]) {
} else { console.error(obj);
return void cb({error: type + ' is disabled'}); store.modules[type].execCommand(clientId, data, cb);
} } else {
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) {
if (!store.cursor) { return void cb ({error: 'Cursor channel is disabled'}); } // The cursor module can only be used when the store is ready
store.cursor.execCommand(clientId, data, cb); onReadyEvt.reg(function () {
if (!store.cursor) { return void cb ({error: 'Cursor channel is disabled'}); }
store.cursor.execCommand(clientId, data, cb);
});
} }
}; };
// Mailbox // Mailbox
Store.mailbox = { Store.mailbox = {
execCommand: function (clientId, data, cb) { execCommand: function (clientId, data, cb) {
if (!store.loggedIn) { return void cb(); } // The mailbox can only be used when the store is ready
if (!store.mailbox) { return void cb ({error: 'Mailbox is disabled'}); } onReadyEvt.reg(function () {
store.mailbox.execCommand(clientId, data, cb); if (!store.loggedIn) { return void cb(); }
if (!store.mailbox) { return void cb ({error: 'Mailbox is disabled'}); }
store.mailbox.execCommand(clientId, data, cb);
});
} }
}; };
@ -2568,8 +2577,8 @@ define([
loadUniversal(History, 'history', waitFor); loadUniversal(History, 'history', waitFor);
cleanFriendRequests(); cleanFriendRequests();
}).nThen(function () { }).nThen(function () {
var requestLogin = function () { var requestLogin = function () {
broadcast([], "REQUEST_LOGIN"); broadcast([], "REQUEST_LOGIN");
}; };
if (store.loggedIn) { if (store.loggedIn) {
@ -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