Handle corrupted cache in OO chainpad

pull/1/head
yflory 4 years ago
parent 5858396985
commit 009e4f9bc8

@ -2514,6 +2514,18 @@ define([
toolbar.$drawer.append($properties); toolbar.$drawer.append($properties);
}; };
var noCache = false; // Prevent reload loops
var onCorruptedCache = function () {
if (noCache) {
UI.errorLoadingScreen(Messages.unableToDisplay, false, function () {
common.gotoURL('');
});
}
noCache = true;
var sframeChan = common.getSframeChannel();
sframeChan.event("EV_CORRUPTED_CACHE");
};
config.onReady = function (info) { config.onReady = function (info) {
if (APP.realtime !== info.realtime) { if (APP.realtime !== info.realtime) {
APP.realtime = info.realtime; APP.realtime = info.realtime;
@ -2546,11 +2558,8 @@ define([
newDoc = !content.hashes || Object.keys(content.hashes).length === 0; newDoc = !content.hashes || Object.keys(content.hashes).length === 0;
} else if (!privateData.isNewFile) { } else if (!privateData.isNewFile) {
// This is an empty doc but not a new file: error // This is an empty doc but not a new file: error
// XXX clear cache before reloading onCorruptedCache();
UI.errorLoadingScreen(Messages.unableToDisplay, false, function () { return void console.error("Empty chainpad for a non-empty doc");
common.gotoURL('');
});
throw new Error("Empty chainpad for a non-empty doc");
} else { } else {
Title.updateTitle(Title.defaultTitle); Title.updateTitle(Title.defaultTitle);
} }

Loading…
Cancel
Save