Merge branch 'whiteboard' into soon

This commit is contained in:
yflory
2020-03-24 16:15:13 +01:00
13 changed files with 167 additions and 108 deletions

View File

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

View File

@@ -259,12 +259,14 @@ define([
};
// Handle disconnect/reconnect
var setEditable = function (state) {
var setEditable = function (state, isHistory) {
if (APP.closed || !APP.$content || !$.contains(document.documentElement, APP.$content[0])) { return; }
APP.editable = !APP.readOnly && state;
if (!state) {
APP.$content.addClass('cp-app-drive-readonly');
$('#cp-app-drive-connection-state').show();
if (!isHistory) {
$('#cp-app-drive-connection-state').show();
}
$('[draggable="true"]').attr('draggable', false);
}
else {
@@ -3865,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;

View File

@@ -104,10 +104,14 @@ define([
return metadataMgr.getNetfluxId() + '-' + privateData.clientId;
};
var getEditor = function () {
return window.frames[0].editor || window.frames[0].editorCell;
};
var setEditable = function (state) {
$('#cp-app-oo-editor').find('#cp-app-oo-offline').remove();
try {
window.frames[0].editor.asc_setViewMode(!state);
getEditor().asc_setViewMode(!state);
//window.frames[0].editor.setViewModeDisconnect(true);
} catch (e) {}
if (!state && !readOnly) {
@@ -241,10 +245,6 @@ define([
cpIndex: 0
};
var getEditor = function () {
return window.frames[0].editor || window.frames[0].editorCell;
};
var getContent = function () {
try {
return getEditor().asc_nativeGetFile();
@@ -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);
});
@@ -846,7 +847,7 @@ define([
"id": String(myOOId), //"c0c3bf82-20d7-4663-bf6d-7fa39c598b1d",
"firstname": metadataMgr.getUserData().name || Messages.anonymous,
},
"mode": readOnly || lock ? "view" : "edit",
"mode": lock ? "view" : "edit",
"lang": (navigator.language || navigator.userLanguage || '').slice(0,2)
},
"events": {
@@ -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 () { });
}

View File

@@ -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) {

View File

@@ -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

View File

@@ -54,6 +54,9 @@ define([
if (!lm.proxy.notifications) {
lm.proxy.notifications = Util.find(ctx.store.proxy, ['mailboxes', 'notifications', 'channel']);
}
if (!lm.proxy.edPublic) {
lm.proxy.edPublic = ctx.store.proxy.edPublic;
}
if (ctx.onReadyHandlers.length) {
ctx.onReadyHandlers.forEach(function (f) {
try {

View File

@@ -203,7 +203,6 @@ define([
var base = exp.getStructure();
return typeof (obj) === "object" &&
Object.keys(base).every(function (key) {
console.log(key, obj[key], type(obj[key]));
return obj[key] && type(base[key]) === type(obj[key]);
});
};