Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
yflory 5 years ago
commit d92122347f

@ -103,7 +103,7 @@ define([
])*/ ])*/
]) ])
]), ]),
h('div.cp-version-footer', "CryptPad v3.0.1 (Aurochs' revenge)") h('div.cp-version-footer', "CryptPad v3.1.0 (Baiji)")
]); ]);
}; };

@ -1,8 +1,7 @@
module.exports = function (f) { module.exports = function (f, g) {
var called;
return function () { return function () {
if (called) { return; } if (!f) { return; }
called = true;
f.apply(this, Array.prototype.slice.call(arguments)); f.apply(this, Array.prototype.slice.call(arguments));
f = g;
}; };
}; };

@ -1,7 +1,7 @@
{ {
"name": "cryptpad", "name": "cryptpad",
"description": "realtime collaborative visual editor with zero knowlege server", "description": "realtime collaborative visual editor with zero knowlege server",
"version": "3.0.1", "version": "3.1.0",
"license": "AGPL-3.0+", "license": "AGPL-3.0+",
"repository": { "repository": {
"type": "git", "type": "git",

@ -294,37 +294,33 @@ var getUploadSize = function (Env, channel, cb) { // FIXME FILES
}); });
}; };
const batchFileSize = BatchRead("GET_FILE_SIZE");
var getFileSize = function (Env, channel, cb) { var getFileSize = function (Env, channel, cb) {
if (!isValidId(channel)) { return void cb('INVALID_CHAN'); } if (!isValidId(channel)) { return void cb('INVALID_CHAN'); }
batchFileSize(channel, cb, function (done) {
if (channel.length === 32) { if (channel.length === 32) {
if (typeof(Env.msgStore.getChannelSize) !== 'function') { if (typeof(Env.msgStore.getChannelSize) !== 'function') {
return done('GET_CHANNEL_SIZE_UNSUPPORTED'); return cb('GET_CHANNEL_SIZE_UNSUPPORTED');
} }
return void Env.msgStore.getChannelSize(channel, function (e, size /*:number*/) { return void Env.msgStore.getChannelSize(channel, function (e, size /*:number*/) {
if (e) { if (e) {
if (e.code === 'ENOENT') { return void done(void 0, 0); } if (e.code === 'ENOENT') { return void cb(void 0, 0); }
return void done(e.code); return void cb(e.code);
} }
done(void 0, size); cb(void 0, size);
}); });
} }
// 'channel' refers to a file, so you need another API // 'channel' refers to a file, so you need another API
getUploadSize(Env, channel, function (e, size) { getUploadSize(Env, channel, function (e, size) {
if (typeof(size) === 'undefined') { return void done(e); } if (typeof(size) === 'undefined') { return void cb(e); }
done(void 0, size); cb(void 0, size);
});
}); });
}; };
const batchMetadata = BatchRead("GET_METADATA"); const batchMetadata = BatchRead("GET_METADATA");
var getMetadata = function (Env, channel, cb) { var getMetadata = function (Env, channel, cb) {
if (!isValidId(channel)) { return void cb('INVALID_CHAN'); } if (!isValidId(channel)) { return void cb('INVALID_CHAN'); }
if (channel.length !== 32) { return cb("INVALID_CHAN_LENGTH"); }
if (channel.length !== 32) { return cb("INVALID_CHAN"); }
batchMetadata(channel, cb, function (done) { batchMetadata(channel, cb, function (done) {
var ref = {}; var ref = {};

@ -76,7 +76,7 @@ var getMetadataAtPath = function (Env, path, cb) {
catch (e) { catch (e) {
console.log("getMetadataAtPath"); console.log("getMetadataAtPath");
console.error(e); console.error(e);
complete('INVALID_METADATA'); complete('INVALID_METADATA', metadata);
} }
}); });
stream.on('end', function () { stream.on('end', function () {

@ -158,14 +158,14 @@ define([
var done = function () { var done = function () {
clearTimeout(timeout); clearTimeout(timeout);
if (btime) { if (btime) {
console.log("Compiling [" + url + "] took " + (+new Date() - btime) + "ms"); console.info("Compiling [" + url + "] took " + (+new Date() - btime) + "ms");
} }
cb(); cb();
}; };
stack.push(url); stack.push(url);
cacheGet(url, function (css) { cacheGet(url, function (css) {
if (css) { return void loadSubmodulesAndInject(css, url, done, stack); } if (css) { return void loadSubmodulesAndInject(css, url, done, stack); }
console.log('CACHE MISS ' + url); console.debug('CACHE MISS ' + url);
((/\.less([\?\#].*)?$/.test(url)) ? loadLess : loadCSS)(url, function (err, css) { ((/\.less([\?\#].*)?$/.test(url)) ? loadLess : loadCSS)(url, function (err, css) {
if (!css) { return void console.error(err); } if (!css) { return void console.error(err); }
var output = fixAllURLs(css, url); var output = fixAllURLs(css, url);

@ -728,6 +728,15 @@ define([
network.on('reconnect', function () { network.on('reconnect', function () {
if (channel && channel.stopped) { return; } if (channel && channel.stopped) { return; }
if (!channels[data.channel]) { return; } if (!channels[data.channel]) { return; }
if (!joining[data.channel]) {
joining[data.channel] = function () {
console.log("reconnected to %s", data.channel);
};
} else {
console.error("Reconnected to a chat channel (%s) which was not fully connected", data.channel);
}
network.join(data.channel).then(onOpen, function (err) { network.join(data.channel).then(onOpen, function (err) {
console.error(err); console.error(err);
}); });

@ -222,13 +222,14 @@
return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER); return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
}; };
Util.noop = function () {};
/* for wrapping async functions such that they can only be called once */ /* for wrapping async functions such that they can only be called once */
Util.once = function (f) { Util.once = function (f, g) {
var called;
return function () { return function () {
if (called) { return; } if (!f) { return; }
called = true;
f.apply(this, Array.prototype.slice.call(arguments)); f.apply(this, Array.prototype.slice.call(arguments));
f = g;
}; };
}; };

@ -1346,7 +1346,7 @@ define([
console.log(parsed); console.log(parsed);
return; return;
} else { } else {
console.log(parsed); //console.log(parsed);
} }
Util.fetch(parsed.href, waitFor(function (err, arraybuffer) { Util.fetch(parsed.href, waitFor(function (err, arraybuffer) {
if (err) { return void console.log(err); } if (err) { return void console.log(err); }

@ -6,7 +6,7 @@ define(['/api/config'], function (ApiConfig) {
var isSupported = Module.isSupported = function () { var isSupported = Module.isSupported = function () {
return typeof(window.Notification) === 'function'; return typeof(window.Notification) === 'function' && window.location.protocol === 'https:';
}; };
var hasPermission = Module.hasPermission = function () { var hasPermission = Module.hasPermission = function () {
@ -52,7 +52,7 @@ define(['/api/config'], function (ApiConfig) {
}; };
var createFavicon = function () { var createFavicon = function () {
console.log("creating favicon"); console.debug("creating favicon");
var fav = document.createElement('link'); var fav = document.createElement('link');
var attrs = { var attrs = {
id: 'favicon', id: 'favicon',

@ -126,7 +126,7 @@ define([
var onMessage = function (data, cb) { var onMessage = function (data, cb) {
// data = { type: 'type', content: {msg: 'msg', hash: 'hash'} } // data = { type: 'type', content: {msg: 'msg', hash: 'hash'} }
console.log(data.type, data.content); console.debug(data.type, data.content);
pushMessage(data); pushMessage(data);
if (data.content && typeof (data.content.getFormatText) == "function") { if (data.content && typeof (data.content.getFormatText) == "function") {
var text = $('<div>').html(data.content.getFormatText()).text(); var text = $('<div>').html(data.content.getFormatText()).text();

Loading…
Cancel
Save