Merge branch 'ooapps' into exportSheet

pull/1/head
yflory 3 years ago
commit 28b0371937

@ -58,11 +58,13 @@ define([
urlArgs: Util.find(ApiConfig, ['requireConf', 'urlArgs']) urlArgs: Util.find(ApiConfig, ['requireConf', 'urlArgs'])
}; };
var CHECKPOINT_INTERVAL = 100; var CHECKPOINT_INTERVAL = 20; // XXX
var FORCE_CHECKPOINT_INTERVAL = 50; // XXX
var DISPLAY_RESTORE_BUTTON = false; var DISPLAY_RESTORE_BUTTON = false;
var NEW_VERSION = 4; var NEW_VERSION = 4; // version of the .bin, patches and ChainPad formats
var PENDING_TIMEOUT = 30000; var PENDING_TIMEOUT = 30000;
var CURRENT_VERSION = X2T.CURRENT_VERSION; var CURRENT_VERSION = X2T.CURRENT_VERSION;
//var READONLY_REFRESH_TO = 15000; //var READONLY_REFRESH_TO = 15000;
var debug = function (x, type) { var debug = function (x, type) {
@ -464,6 +466,9 @@ define([
delete APP.refreshPopup; delete APP.refreshPopup;
clearTimeout(APP.refreshRoTo); clearTimeout(APP.refreshRoTo);
// Don't create the initial checkpoint indefinitely in a loop
delete APP.initCheckpoint;
if (!isLockedModal.modal) { if (!isLockedModal.modal) {
isLockedModal.modal = UI.openCustomModal(isLockedModal.content); isLockedModal.modal = UI.openCustomModal(isLockedModal.content);
} }
@ -525,8 +530,9 @@ define([
var locked = content.saveLock; var locked = content.saveLock;
var lastCp = getLastCp(); var lastCp = getLastCp();
var needCp = force || ooChannel.cpIndex % CHECKPOINT_INTERVAL === 0 || var currentIdx = ooChannel.cpIndex;
(ooChannel.cpIndex - (lastCp.index || 0)) > CHECKPOINT_INTERVAL; var needCp = force || (currentIdx - (lastCp.index || 0)) > FORCE_CHECKPOINT_INTERVAL;
if (!needCp) { return; } if (!needCp) { return; }
if (!locked || !isUserOnline(locked) || force) { if (!locked || !isUserOnline(locked) || force) {
@ -1703,10 +1709,15 @@ define([
} catch (e) {} } catch (e) {}
} }
if (lock && !readOnly) { if (lock && !readOnly) { // Lock = !history && migrate
onMigrateRdy.fire(); onMigrateRdy.fire();
} }
if (APP.initCheckpoint) {
getEditor().asc_setRestriction(true);
makeCheckpoint(true);
}
// Check if history can/should be trimmed // Check if history can/should be trimmed
var cp = getLastCp(); var cp = getLastCp();
if (cp && cp.file && cp.hash) { if (cp && cp.file && cp.hash) {
@ -2763,6 +2774,21 @@ define([
oldHashes = JSON.parse(JSON.stringify(content.hashes)); oldHashes = JSON.parse(JSON.stringify(content.hashes));
initializing = false; initializing = false;
// If we have more than CHECKPOINT_INTERVAL patches in the initial history
// and we're the only editor in the pad, make a checkpoint
var userData = metadataMgr.getMetadata().users;
var v = metadataMgr.getViewers();
var m = metadataMgr.getChannelMembers().filter(function (str) {
return str.length === 32;
}).length;
if ((m - v) === 1 && !readOnly) {
var l = ooChannel.queue.length;
var lastCp = getLastCp();
var needCp = ooChannel.queue.length > CHECKPOINT_INTERVAL;
APP.initCheckpoint = needCp;
}
common.openPadChat(APP.onLocal); common.openPadChat(APP.onLocal);
if (!readOnly) { if (!readOnly) {

Loading…
Cancel
Save