Add a way to restore broken spreadsheets

pull/1/head
yflory 5 years ago
parent f5444e5d3d
commit 16549f40bb

@ -48,6 +48,7 @@ define([
};
var CHECKPOINT_INTERVAL = 50;
var DISPLAY_RESTORE_BUTTON = false;
var debug = function (x) {
if (!window.CP_DEV_MODE) { return; }
@ -237,13 +238,7 @@ define([
}
};
var fmConfig = {
noHandlers: true,
noStore: true,
body: $('body'),
onUploaded: function (ev, data) {
if (!data || !data.url) { return; }
sframeChan.query('Q_OO_SAVE', data, function (err) {
var onUploaded = function (ev, data, err) {
if (err) {
console.error(err);
return void UI.alert(Messages.oo_saveError);
@ -270,6 +265,16 @@ define([
}, function (err, obj) {
if (err || (obj && obj.error)) { console.error(err || obj.error); }
});
};
var fmConfig = {
noHandlers: true,
noStore: true,
body: $('body'),
onUploaded: function (ev, data) {
if (!data || !data.url) { return; }
sframeChan.query('Q_OO_SAVE', data, function (err) {
onUploaded(ev, data, err);
});
}
};
@ -307,6 +312,19 @@ define([
}
}, to);
};
var restoreLastCp = function () {
content.saveLock = myOOId;
APP.onLocal();
APP.realtime.onSettle(function () {
onUploaded({
hash: ooChannel.lastHash,
index: ooChannel.cpIndex
}, {
url: getLastCp().file,
});
});
};
var openRtChannel = function (cb) {
if (rtChannel.ready) { return void cb(); }
@ -880,6 +898,16 @@ define([
});
$save.appendTo($rightside);
}
if (window.CP_DEV_MODE || DISPLAY_RESTORE_BUTTON) {
common.createButton('', true, {
name: 'restore',
icon: 'fa-history',
hiddenReadOnly: true
}).click(function () {
if (initializing) { return void console.error('initializing'); }
restoreLastCp();
}).attr('title', 'Restore last checkpoint').appendTo($rightside);
}
var $export = common.createButton('export', true, {}, exportFile);
$export.appendTo($rightside);

Loading…
Cancel
Save