Fix race condition in framework

pull/1/head
yflory 4 years ago
parent 384200860b
commit e8cdbf6630

@ -221,6 +221,10 @@ define([
evStart.reg(function () { toolbar.deleted(); }); evStart.reg(function () { toolbar.deleted(); });
break; break;
} }
case STATE.READY: {
evStart.reg(function () { toolbar.ready(); });
break;
}
default: default:
} }
var isEditable = (state === STATE.READY && !unsyncMode); var isEditable = (state === STATE.READY && !unsyncMode);
@ -479,7 +483,7 @@ define([
sframeChan.event("EV_CORRUPTED_CACHE"); sframeChan.event("EV_CORRUPTED_CACHE");
}; };
var onCacheReady = function () { var onCacheReady = function () {
stateChange(STATE.DISCONNECTED); stateChange(STATE.INITIALIZING);
toolbar.offline(true); toolbar.offline(true);
var newContentStr = cpNfInner.chainpad.getUserDoc(); var newContentStr = cpNfInner.chainpad.getUserDoc();
if (toolbar) { if (toolbar) {
@ -526,7 +530,6 @@ define([
var privateDat = cpNfInner.metadataMgr.getPrivateData(); var privateDat = cpNfInner.metadataMgr.getPrivateData();
var type = privateDat.app; var type = privateDat.app;
// contentUpdate may be async so we need an nthen here // contentUpdate may be async so we need an nthen here
nThen(function (waitFor) { nThen(function (waitFor) {
if (!newPad) { if (!newPad) {
@ -783,7 +786,7 @@ define([
onRemote: onRemote, onRemote: onRemote,
onLocal: onLocal, onLocal: onLocal,
onInit: onInit, onInit: onInit,
onCacheReady: onCacheReady, onCacheReady: function () { evStart.reg(onCacheReady); },
onReady: function () { evStart.reg(onReady); }, onReady: function () { evStart.reg(onReady); },
onConnectionChange: onConnectionChange, onConnectionChange: onConnectionChange,
onError: onError, onError: onError,

@ -1318,6 +1318,10 @@ MessengerUI, Messages) {
toolbar.spinner.text(Messages.reconnecting); toolbar.spinner.text(Messages.reconnecting);
} }
}; };
toolbar.ready = function () {
toolbar.connected = true;
kickSpinner(toolbar, config);
};
toolbar.errorState = function (state, error) { toolbar.errorState = function (state, error) {
toolbar.isErrorState = state; toolbar.isErrorState = state;

Loading…
Cancel
Save