Fix the infinite spinner bug with the file manager store

pull/1/head
yflory 8 years ago
parent 43ccd11adc
commit ee56f5608f

@ -153,8 +153,15 @@ define([
} }
onReady(f, rt.proxy, Cryptpad.storageKey); onReady(f, rt.proxy, Cryptpad.storageKey);
}) })
.on('disconnect', function () { .on('disconnect', function (info) {
//setEditable(false); //setEditable(false);
if (info.error) {
//Cryptpad.alert(Messages.websocketError);
if (typeof Cryptpad.storeError === "function") {
Cryptpad.storeError();
}
return;
}
Cryptpad.alert(Messages.common_connectionLost); Cryptpad.alert(Messages.common_connectionLost);
}); });

@ -21,6 +21,7 @@ define(function () {
].join(''); ].join('');
out.common_connectionLost = 'Server Connection Lost'; out.common_connectionLost = 'Server Connection Lost';
out.websocketError = 'Unable to connect to the websocket server...';
out.disconnected = 'Disconnected'; out.disconnected = 'Disconnected';
out.synchronizing = 'Synchronizing'; out.synchronizing = 'Synchronizing';

@ -42,6 +42,11 @@ define([
secret.keys = secret.key; secret.keys = secret.key;
} }
var onConnectError = function (info) {
module.spinner.hide();
Cryptpad.alert(Messages.websocketError);
};
var andThen = function (CMeditor) { var andThen = function (CMeditor) {
var CodeMirror = module.CodeMirror = CMeditor; var CodeMirror = module.CodeMirror = CMeditor;
CodeMirror.modeURL = "/bower_components/codemirror/mode/%N/%N.js"; CodeMirror.modeURL = "/bower_components/codemirror/mode/%N/%N.js";
@ -687,10 +692,7 @@ define([
} }
}; };
var onError = config.onError = function (info) { var onError = config.onError = onConnectError();
module.spinner.hide();
Cryptpad.alert(Messages.websocketError);
};
var realtime = module.realtime = Realtime.start(config); var realtime = module.realtime = Realtime.start(config);
@ -704,6 +706,11 @@ define([
// TODO handle error // TODO handle error
andThen(CM); andThen(CM);
}); });
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
}; };
var first = function () { var first = function () {

@ -649,6 +649,19 @@ define([
}, common); }, common);
}; };
var errorHandlers = [];
common.onError = function (h) {
if (typeof h !== "function") { return; }
errorHandlers.push(h);
};
common.storeError = function () {
errorHandlers.forEach(function (h) {
if (typeof h === "function") {
h({type: "store"});
}
});
};
/* /*
* Saving files * Saving files
*/ */
@ -877,9 +890,9 @@ define([
var $link = $('link[href="/customize/alertify.css"]'); var $link = $('link[href="/customize/alertify.css"]');
if ($link.length) { if ($link.length) {
return; return;
$link.attr('href', ''); /*$link.attr('href', '');
$link.attr('href', '/customize/alertify.css'); $link.attr('href', '/customize/alertify.css');
return; return;*/
} }
href = href || '/customize/alertify.css'; href = href || '/customize/alertify.css';

@ -77,6 +77,11 @@ define([
return hj; return hj;
}; };
var onConnectError = function (info) {
module.spinner.hide();
Cryptpad.alert(Messages.websocketError);
};
var andThen = function (Ckeditor) { var andThen = function (Ckeditor) {
var secret = Cryptpad.getSecrets(); var secret = Cryptpad.getSecrets();
var readOnly = secret.keys && !secret.keys.editKeyStr; var readOnly = secret.keys && !secret.keys.editKeyStr;
@ -691,10 +696,7 @@ define([
} }
}; };
var onError = realtimeOptions.onError = function (info) { var onError = realtimeOptions.onError = onConnectError;
module.spinner.hide();
Cryptpad.alert(Messages.websocketError);
};
var onLocal = realtimeOptions.onLocal = function () { var onLocal = realtimeOptions.onLocal = function () {
if (initializing) { return; } if (initializing) { return; }
@ -741,6 +743,11 @@ define([
// TODO handle error // TODO handle error
andThen(Ckeditor); andThen(Ckeditor);
}); });
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
}; };
var first = function () { var first = function () {

@ -662,6 +662,10 @@ define([
var disconnect = function () { var disconnect = function () {
//setEditable(false); // TODO //setEditable(false); // TODO
if (info.error) {
Cryptpad.alert(Messages.websocketError);
return;
}
//Cryptpad.alert(Messages.common_connectionLost); // TODO //Cryptpad.alert(Messages.common_connectionLost); // TODO
}; };

@ -59,6 +59,11 @@ define([
var presentMode = Slide.isPresentURL(); var presentMode = Slide.isPresentURL();
var onConnectError = function (info) {
module.spinner.hide();
Cryptpad.alert(Messages.websocketError);
};
var andThen = function (CMeditor) { var andThen = function (CMeditor) {
var CodeMirror = module.CodeMirror = CMeditor; var CodeMirror = module.CodeMirror = CMeditor;
CodeMirror.modeURL = "/bower_components/codemirror/mode/%N/%N.js"; CodeMirror.modeURL = "/bower_components/codemirror/mode/%N/%N.js";
@ -786,10 +791,7 @@ define([
} }
}; };
var onError = config.onError = function (info) { var onError = config.onError = onConnectError;
module.spinner.hide();
Cryptpad.alert(Messages.websocketError);
};
var realtime = module.realtime = Realtime.start(config); var realtime = module.realtime = Realtime.start(config);
@ -803,6 +805,11 @@ define([
// TODO handle error // TODO handle error
andThen(CM); andThen(CM);
}); });
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
}; };
var first = function () { var first = function () {

Loading…
Cancel
Save