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

This commit is contained in:
yflory
2017-12-22 16:25:52 +01:00
6 changed files with 65 additions and 8 deletions

View File

@@ -252,6 +252,14 @@ define([
});
};
common.isNewChannel = function (href, cb) {
postMessage('IS_NEW_CHANNEL', {href: href}, function (obj) {
if (obj.error) { return void cb(obj.error); }
if (!obj) { return void cb('INVALID_RESPONSE'); }
cb(undefined, obj.isNew);
});
};
// Store

View File

@@ -277,6 +277,21 @@ define([
});
};
Store.isNewChannel = function (data, cb) {
if (!store.anon_rpc) { return void cb({error: 'ANON_RPC_NOT_READY'}); }
var channelId = Hash.hrefToHexChannelId(data.href);
store.anon_rpc.send("IS_NEW_CHANNEL", channelId, function (e, response) {
if (e) { return void cb({error: e}); }
if (response && response.length && typeof(response[0]) === 'boolean') {
return void cb({
isNew: response[0]
});
} else {
cb({error: 'INVALID_RESPONSE'});
}
});
};
Store.getMultipleFileSize = function (data, cb) {
if (!store.anon_rpc) { return void cb({error: 'ANON_RPC_NOT_READY'}); }
if (!Array.isArray(data.files)) {

View File

@@ -160,8 +160,13 @@ define([
case 'DRIVE_USEROBJECT': {
Store.userObjectCommand(data, cb); break;
}
case 'IS_NEW_CHANNEL': {
Store.isNewChannel(data, cb); break;
}
default: {
console.error("UNHANDLED_STORE_RPC");
break;
}
}

View File

@@ -103,7 +103,7 @@ define([
});
sframeChan.on('Q_RT_MESSAGE', function (content, cb) {
if (isReady) {
onLocal(); // should be onBeforeMessage
onLocal(true); // should be onBeforeMessage
}
chainpad.message(content);
cb('OK');

View File

@@ -140,12 +140,10 @@ define([
}).nThen(function (waitFor) {
// Check if the pad exists on server
if (!window.location.hash) { isNewFile = true; return; }
Cryptpad.getFileSize(window.location.href, waitFor(function (err, size) {
if (size) {
isNewFile = false;
return;
}
isNewFile = true;
Cryptpad.isNewChannel(window.location.href, waitFor(function (e, isNew) {
if (e) { return console.error(e); }
isNewFile = Boolean(isNew);
}));
}).nThen(function () {
var readOnly = secret.keys && !secret.keys.editKeyStr;