make infinite spinner error message go away if ChainPad settles after it has been popped

pull/1/head
Caleb James DeLisle 7 years ago
parent 753e2d797e
commit 854c1e94a4

@ -10,6 +10,7 @@ define([
'/common/sframe-common.js',
'/customize/messages.js',
'/common/common-util.js',
'/customize/application_config.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
@ -25,7 +26,8 @@ define([
nThen,
SFCommon,
Messages,
Util)
Util,
AppConfig)
{
var SaveAs = window.saveAs;
@ -40,6 +42,9 @@ define([
READY: 'READY'
});
var badStateTimeout = typeof(AppConfig.badStateTimeout) === 'number' ?
AppConfig.badStateTimeout : 30000;
var onConnectError = function () {
Cryptpad.errorLoadingScreen(Messages.websocketError);
};
@ -101,7 +106,7 @@ define([
var stateChange = function (newState) {
var wasEditable = (state === STATE.READY);
if (state === STATE.INFINITE_SPINNER) { return; }
if (state === STATE.INFINITE_SPINNER && newState !== STATE.READY) { return; }
if (newState === STATE.INFINITE_SPINNER) {
state = newState;
} else if (state === STATE.DISCONNECTED && newState !== STATE.INITIALIZING) {
@ -365,15 +370,27 @@ define([
textPatcher = TextPatcher.create({ realtime: cpNfInner.chainpad });
cpNfInner.onInfiniteSpinner(function () {
toolbar.failed();
cpNfInner.chainpad.abort();
window.setInterval(function () {
if (state === STATE.DISCONNECTED) { return; }
var l;
try {
l = cpNfInner.chainpad.getLag();
} catch (e) {
throw new Error("ChainPad.getLag() does not exist, please `bower update`");
}
if (l.lag < badStateTimeout) { return; }
stateChange(STATE.INFINITE_SPINNER);
Cryptpad.confirm(Messages.realtime_unrecoverableError, function (yes) {
if (!yes) { return; }
common.gotoURL();
});
cpNfInner.chainpad.onSettle(function () {
Cryptpad.findCancelButton().click();
stateChange(STATE.READY);
onRemote();
});
}, 2000);
//Cryptpad.onLogout(function () { ... });

@ -75,7 +75,6 @@ define([
throw new Error("ChainPad.getLag() does not exist, please `bower update`");
}
if (l.lag < badStateTimeout) { return; }
chainpad.abort();
evInfiniteSpinner.fire();
}, 2000);

Loading…
Cancel
Save