Hide infinite spinner and disconnect modals when pad is deleted

pull/1/head
yflory 7 years ago
parent ef0c08130d
commit 70e014cdfc

@ -160,5 +160,11 @@
} }
} }
} }
.cp-creation-deleted {
background: #111;
padding: 10px;
text-align: justify;
font-weight: bold;
}
} }
} }

@ -1829,5 +1829,24 @@ define([
}, Messages.creation_settings))).appendTo($creation); }, Messages.creation_settings))).appendTo($creation);
}; };
UIElements.onServerError = function (common, err, toolbar, cb) {
if (["EDELETED", "EEXPIRED"].indexOf(err.type) === -1) { return; }
var msg = err.type;
if (err.type === 'EEXPIRED') {
msg = Messages.expiredError;
if (err.loaded) {
msg += Messages.expiredErrorCopy;
}
} else if (err.type === 'EDELETED') {
msg = Messages.deletedError;
if (err.loaded) {
msg += Messages.expiredErrorCopy;
}
}
if (toolbar && typeof toolbar.deleted === "function") { toolbar.deleted(); }
UI.errorLoadingScreen(msg, true, true);
(cb || function () {})();
};
return UIElements; return UIElements;
}); });

@ -333,20 +333,9 @@ define([
}; };
var onError = function (err) { var onError = function (err) {
stateChange(STATE.DELETED); common.onServerError(err, toolbar, function () {
var msg = err.type; stateChange(STATE.DELETED);
if (err.type === 'EEXPIRED') { });
msg = Messages.expiredError;
if (err.loaded) {
msg += Messages.expiredErrorCopy;
}
} else if (err.type === 'EDELETED') {
msg = Messages.deletedError;
if (err.loaded) {
msg += Messages.expiredErrorCopy;
}
}
UI.errorLoadingScreen(msg, true, true);
}; };
var setFileExporter = function (extension, fe, async) { var setFileExporter = function (extension, fe, async) {

@ -92,6 +92,7 @@ define([
funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar); funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar);
funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen); funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen);
funcs.createNewPadModal = callWithCommon(UIElements.createNewPadModal); funcs.createNewPadModal = callWithCommon(UIElements.createNewPadModal);
funcs.onServerError = callWithCommon(UIElements.onServerError);
// Thumb // Thumb
funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail); funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail);

@ -1130,27 +1130,20 @@ define([
// Manage disconnections because of network or error // Manage disconnections because of network or error
var onDisconnect = function (info) { var onDisconnect = function (info) {
setEditable(false); if (APP.unrecoverable) { return; }
if (info && ['EEXPIRED', 'EDELETED'].indexOf(info.type) !== -1) { if (info && info.type) {
APP.toolbar.deleted(); // Server error
var msg = info.type; return void common.onServerError(info, APP.toolbar, function () {
if (info.type === 'EEXPIRED') { APP.unrecoverable = true;
msg = Messages.expiredError; setEditable(false);
if (info.loaded) { });
msg += Messages.expiredErrorCopy;
}
} else if (info.type === 'EDELETED') {
msg = Messages.deletedError;
if (info.loaded) {
msg += Messages.expiredErrorCopy;
}
}
return void UI.errorLoadingScreen(msg, true, true);
} }
setEditable(false);
UI.alert(Messages.common_connectionLost, undefined, true); UI.alert(Messages.common_connectionLost, undefined, true);
}; };
var onReconnect = function () { var onReconnect = function () {
if (APP.unrecoverable) { return; }
setEditable(true); setEditable(true);
UI.findOKButton().click(); UI.findOKButton().click();
}; };

@ -598,6 +598,7 @@ define([
}; };
config.onAbort = function () { config.onAbort = function () {
if (APP.unrecoverable) { return; }
// inform of network disconnect // inform of network disconnect
setEditable(false); setEditable(false);
toolbar.failed(); toolbar.failed();
@ -605,6 +606,7 @@ define([
}; };
config.onConnectionChange = function (info) { config.onConnectionChange = function (info) {
if (APP.unrecoverable) { return; }
setEditable(info.state); setEditable(info.state);
if (info.state) { if (info.state) {
initializing = true; initializing = true;
@ -615,27 +617,17 @@ define([
}; };
config.onError = function (err) { config.onError = function (err) {
setEditable(false); common.onServerError(err, toolbar, function () {
toolbar.deleted(); APP.unrecoverable = true;
var msg = err.type; setEditable(false);
if (err.type === 'EEXPIRED') { });
msg = Messages.expiredError;
if (err.loaded) {
msg += Messages.expiredErrorCopy;
}
} else if (err.type === 'EDELETED') {
msg = Messages.deletedError;
if (err.loaded) {
msg += Messages.expiredErrorCopy;
}
}
UI.errorLoadingScreen(msg, true, true);
}; };
cpNfInner = common.startRealtime(config); cpNfInner = common.startRealtime(config);
metadataMgr = cpNfInner.metadataMgr; metadataMgr = cpNfInner.metadataMgr;
cpNfInner.onInfiniteSpinner(function () { cpNfInner.onInfiniteSpinner(function () {
if (APP.unrecoverable) { return; }
setEditable(false); setEditable(false);
UI.confirm(Messages.realtime_unrecoverableError, function (yes) { UI.confirm(Messages.realtime_unrecoverableError, function (yes) {
if (!yes) { return; } if (!yes) { return; }

Loading…
Cancel
Save