Fix issues with trim history in spreadsheets
parent
a13561eb8d
commit
8e8b371690
|
@ -803,6 +803,17 @@ define([
|
|||
var chan = [data.channel];
|
||||
if (data.rtChannel) { chan.push(data.rtChannel); }
|
||||
if (data.lastVersion) { chan.push(Hash.hrefToHexChannelId(data.lastVersion)); }
|
||||
var channels = chan.filter(function (c) { return c.length === 32; }).map(function (id) {
|
||||
if (id === data.rtChannel && data.lastVersion && data.lastCpHash) {
|
||||
return {
|
||||
channel: id,
|
||||
lastKnownHash: data.lastCpHash
|
||||
};
|
||||
}
|
||||
return {
|
||||
channel: id
|
||||
};
|
||||
});
|
||||
var history = common.makeUniversal('history');
|
||||
var trimChannels = [];
|
||||
NThen(function (waitFor) {
|
||||
|
@ -819,7 +830,7 @@ define([
|
|||
if (!owned) { return; }
|
||||
history.execCommand('GET_HISTORY_SIZE', {
|
||||
pad: true,
|
||||
channels: chan.filter(function (c) { return c.length === 32; }),
|
||||
channels: channels,
|
||||
teamId: typeof(owned) === "number" && owned
|
||||
}, waitFor(function (obj) {
|
||||
if (obj && obj.error) { return; }
|
||||
|
|
|
@ -3867,6 +3867,7 @@ define([
|
|||
|
||||
var opts = {};
|
||||
opts.href = Hash.getRelativeHref(data.href || data.roHref);
|
||||
opts.channel = data.channel;
|
||||
|
||||
if (manager.isSharedFolder(el)) {
|
||||
var ro = folders[el] && folders[el].version >= 2;
|
||||
|
|
|
@ -325,6 +325,7 @@ define([
|
|||
body: $('body'),
|
||||
onUploaded: function (ev, data) {
|
||||
if (!data || !data.url) { return; }
|
||||
data.hash = ev.hash;
|
||||
sframeChan.query('Q_OO_SAVE', data, function (err) {
|
||||
onUploaded(ev, data, err);
|
||||
});
|
||||
|
@ -1556,6 +1557,7 @@ define([
|
|||
content = hjson.content || content;
|
||||
var newLatest = getLastCp();
|
||||
sframeChan.query('Q_OO_SAVE', {
|
||||
hash: newLatest.hash,
|
||||
url: newLatest.file
|
||||
}, function () { });
|
||||
newDoc = !content.hashes || Object.keys(content.hashes).length === 0;
|
||||
|
@ -1649,6 +1651,7 @@ define([
|
|||
var newLatest = getLastCp();
|
||||
if (newLatest.index > latest.index) {
|
||||
sframeChan.query('Q_OO_SAVE', {
|
||||
hash: newLatest.hash,
|
||||
url: newLatest.file
|
||||
}, function () { });
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ define([
|
|||
if (e) { return void cb(e); }
|
||||
Cryptpad.setPadAttribute('lastVersion', data.url, cb);
|
||||
});
|
||||
Cryptpad.setPadAttribute('lastCpHash', data.hash, cb);
|
||||
});
|
||||
sframeChan.on('Q_OO_OPENCHANNEL', function (data, cb) {
|
||||
Cryptpad.getPadAttribute('rtChannel', function (err, res) {
|
||||
|
|
|
@ -36,6 +36,7 @@ define([
|
|||
return void cb();
|
||||
}
|
||||
|
||||
var txid = Math.floor(Math.random() * 1000000);
|
||||
var onOpen = function (wc) {
|
||||
|
||||
ctx.channels[channel] = ctx.channels[channel] || {
|
||||
|
@ -91,6 +92,7 @@ define([
|
|||
|
||||
var hk = network.historyKeeper;
|
||||
var cfg = {
|
||||
txid: txid,
|
||||
lastKnownHash: chan.lastKnownHash || chan.lastCpHash,
|
||||
metadata: {
|
||||
validateKey: obj.validateKey,
|
||||
|
@ -121,6 +123,8 @@ define([
|
|||
} catch (e) {}
|
||||
if (!parsed) { return; }
|
||||
|
||||
// If there is a txid, make sure it's ours or abort
|
||||
if (parsed.txid && parsed.txid !== txid) { return; }
|
||||
|
||||
// Keep only metadata messages for the current channel
|
||||
if (parsed.channel && parsed.channel !== channel) { return; }
|
||||
|
@ -138,6 +142,11 @@ define([
|
|||
}
|
||||
if (parsed.error && parsed.channel) { return; }
|
||||
|
||||
// If there is a txid, make sure it's ours or abort
|
||||
if (Array.isArray(parsed) && parsed[0] && parsed[0] !== txid) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg = parsed[4];
|
||||
|
||||
// Keep only the history for our channel
|
||||
|
|
Loading…
Reference in New Issue