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);
};
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;
});

@ -333,20 +333,9 @@ define([
};
var onError = function (err) {
common.onServerError(err, toolbar, function () {
stateChange(STATE.DELETED);
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;
}
}
UI.errorLoadingScreen(msg, true, true);
});
};
var setFileExporter = function (extension, fe, async) {

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

@ -1130,27 +1130,20 @@ define([
// Manage disconnections because of network or error
var onDisconnect = function (info) {
if (APP.unrecoverable) { return; }
if (info && info.type) {
// Server error
return void common.onServerError(info, APP.toolbar, function () {
APP.unrecoverable = true;
setEditable(false);
if (info && ['EEXPIRED', 'EDELETED'].indexOf(info.type) !== -1) {
APP.toolbar.deleted();
var msg = info.type;
if (info.type === 'EEXPIRED') {
msg = Messages.expiredError;
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);
};
var onReconnect = function () {
if (APP.unrecoverable) { return; }
setEditable(true);
UI.findOKButton().click();
};

@ -598,6 +598,7 @@ define([
};
config.onAbort = function () {
if (APP.unrecoverable) { return; }
// inform of network disconnect
setEditable(false);
toolbar.failed();
@ -605,6 +606,7 @@ define([
};
config.onConnectionChange = function (info) {
if (APP.unrecoverable) { return; }
setEditable(info.state);
if (info.state) {
initializing = true;
@ -615,27 +617,17 @@ define([
};
config.onError = function (err) {
common.onServerError(err, toolbar, function () {
APP.unrecoverable = true;
setEditable(false);
toolbar.deleted();
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;
}
}
UI.errorLoadingScreen(msg, true, true);
});
};
cpNfInner = common.startRealtime(config);
metadataMgr = cpNfInner.metadataMgr;
cpNfInner.onInfiniteSpinner(function () {
if (APP.unrecoverable) { return; }
setEditable(false);
UI.confirm(Messages.realtime_unrecoverableError, function (yes) {
if (!yes) { return; }

Loading…
Cancel
Save