diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 57f31905a..720c0947e 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1378,13 +1378,16 @@ define([ // Universal Store.universal = { execCommand: function (clientId, obj, cb) { - var type = obj.type; - var data = obj.data; - if (store.modules[type]) { - store.modules[type].execCommand(clientId, data, cb); - } else { - return void cb({error: type + ' is disabled'}); - } + onReadyEvt.reg(function () { + var type = obj.type; + var data = obj.data; + if (store.modules[type]) { + console.error(obj); + store.modules[type].execCommand(clientId, data, cb); + } else { + return void cb({error: type + ' is disabled'}); + } + }); } }; var loadUniversal = function (Module, type, waitFor, clientId) { @@ -1424,17 +1427,23 @@ define([ // Cursor Store.cursor = { execCommand: function (clientId, data, cb) { - if (!store.cursor) { return void cb ({error: 'Cursor channel is disabled'}); } - store.cursor.execCommand(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'}); } + store.cursor.execCommand(clientId, data, cb); + }); } }; // Mailbox Store.mailbox = { execCommand: function (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); + // The mailbox can only be used when the store is ready + onReadyEvt.reg(function () { + 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); cleanFriendRequests(); }).nThen(function () { - var requestLogin = function () { - broadcast([], "REQUEST_LOGIN"); + var requestLogin = function () { + broadcast([], "REQUEST_LOGIN"); }; if (store.loggedIn) { @@ -2664,9 +2673,9 @@ define([ broadcast([], "UPDATE_TOKEN", { token: proxy[Constants.tokenKey] }); }); - onReadyEvt.fire(); - loadMailbox(); + + onReadyEvt.fire(); }); }; diff --git a/www/drive/inner.js b/www/drive/inner.js index 364d4a9d9..d4ac14746 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -310,7 +310,6 @@ define([ onDisconnect(); }); sframeChan.on('EV_NETWORK_RECONNECT', function () { - console.log('here'); onReconnect(); }); common.onLogout(function () { setEditable(false); });