Use the same network for the apps and the file store

pull/1/head
yflory 8 years ago
parent 004d4a16fe
commit 1e70af0c16

@ -155,6 +155,7 @@ define([
crypto: Crypto.createEncryptor(secret.keys), crypto: Crypto.createEncryptor(secret.keys),
setMyID: setMyID, setMyID: setMyID,
transformFunction: JsonOT.transform || JsonOT.validate, transformFunction: JsonOT.transform || JsonOT.validate,
network: Cryptpad.getNetwork()
}; };
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); }; var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };

@ -43,6 +43,14 @@ define([
if (USE_FS_STORE && !legacy && fsStore) { return fsStore; } if (USE_FS_STORE && !legacy && fsStore) { return fsStore; }
throw new Error("Store is not ready!"); throw new Error("Store is not ready!");
}; };
var getNetwork = common.getNetwork = function () {
if (USE_FS_STORE && fsStore) {
if (fsStore.getProxy() && fsStore.getProxy().info) {
return fsStore.getProxy().info.network;
}
}
return;
};
var getWebsocketURL = common.getWebsocketURL = function () { var getWebsocketURL = common.getWebsocketURL = function () {
if (!Config.websocketPath) { return Config.websocketURL; } if (!Config.websocketPath) { return Config.websocketURL; }

@ -688,9 +688,6 @@ define([
var before = JSON.stringify(files); var before = JSON.stringify(files);
var fixRoot = function (elem) { var fixRoot = function (elem) {
if (typeof(files[ROOT]) !== "object") { debug("ROOT was not an object"); files[ROOT] = {}; } if (typeof(files[ROOT]) !== "object") { debug("ROOT was not an object"); files[ROOT] = {}; }
var element = elem || files[ROOT]; var element = elem || files[ROOT];

@ -376,6 +376,9 @@ define([
// the channel we will communicate over // the channel we will communicate over
channel: secret.channel, channel: secret.channel,
// the nework used for the file store if it exists
network: Cryptpad.getNetwork(),
// our public key // our public key
validateKey: secret.keys.validateKey || undefined, validateKey: secret.keys.validateKey || undefined,
readOnly: readOnly, readOnly: readOnly,
@ -629,6 +632,11 @@ define([
var onReady = realtimeOptions.onReady = function (info) { var onReady = realtimeOptions.onReady = function (info) {
if (!APP.isMaximized) { if (!APP.isMaximized) {
editor.execCommand('maximize'); editor.execCommand('maximize');
// We have to call it 3 times in Safari in order to have the editor fully maximized -_-
if ((''+window.navigator.vendor).indexOf('Apple') !== -1) {
editor.execCommand('maximize');
editor.execCommand('maximize');
}
APP.isMaximized = true; APP.isMaximized = true;
} }

@ -698,6 +698,8 @@ define([
Cryptpad.alert(Messages.common_connectionLost); Cryptpad.alert(Messages.common_connectionLost);
}; };
// don't initialize until the store is ready.
Cryptpad.ready(function () {
var config = { var config = {
websocketURL: Cryptpad.getWebsocketURL(), websocketURL: Cryptpad.getWebsocketURL(),
channel: secret.channel, channel: secret.channel,
@ -708,10 +710,9 @@ define([
//readOnly: readOnly, //readOnly: readOnly,
crypto: Crypto.createEncryptor(secret.keys), crypto: Crypto.createEncryptor(secret.keys),
userName: 'poll', userName: 'poll',
network: Cryptpad.getNetwork()
}; };
// don't initialize until the store is ready.
Cryptpad.ready(function () {
if (readOnly) { if (readOnly) {
$('#commit, #create-user, #create-option, #publish, #admin').remove(); $('#commit, #create-user, #create-option, #publish, #admin').remove();
} }

@ -195,7 +195,8 @@ define([
readOnly: readOnly, readOnly: readOnly,
crypto: Crypto.createEncryptor(secret.keys), crypto: Crypto.createEncryptor(secret.keys),
setMyID: setMyID, setMyID: setMyID,
transformFunction: JsonOT.validate transformFunction: JsonOT.validate,
network: Cryptpad.getNetwork()
}; };
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); }; var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };

Loading…
Cancel
Save