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

pull/1/head
yflory 7 years ago
commit 91e36171eb

@ -9,6 +9,7 @@ define([
var module = { exports: {} }; var module = { exports: {} };
var key = Config.requireConf.urlArgs; var key = Config.requireConf.urlArgs;
var localStorage = {}; var localStorage = {};
if (!window.cryptpadCache) {
try { try {
localStorage = window.localStorage || {}; localStorage = window.localStorage || {};
if (localStorage['LESS_CACHE'] !== key) { if (localStorage['LESS_CACHE'] !== key) {
@ -22,6 +23,7 @@ define([
console.error(e); console.error(e);
localStorage = {}; localStorage = {};
} }
}
var cacheGet = function (k, cb) { var cacheGet = function (k, cb) {
if (window.cryptpadCache) { return void window.cryptpadCache.get(k, cb); } if (window.cryptpadCache) { return void window.cryptpadCache.get(k, cb); }

@ -18,7 +18,8 @@ define([], function () {
fire: function () { fire: function () {
if (fired) { return; } if (fired) { return; }
fired = true; fired = true;
handlers.forEach(function (h) { h(); }); var args = Array.prototype.slice.call(arguments);
handlers.forEach(function (h) { h.apply(null, args); });
} }
}; };
}; };

@ -46,7 +46,21 @@ define([
var metadataMgr = config.metadataMgr; var metadataMgr = config.metadataMgr;
config = undefined; config = undefined;
var chainpad; var chainpad = ChainPad.create({
userName: userName,
initialState: initialState,
transformFunction: transformFunction,
validateContent: validateContent,
avgSyncMilliseconds: avgSyncMilliseconds,
logLevel: logLevel
});
chainpad.onMessage(function(message, cb) {
sframeChan.query('Q_RT_MESSAGE', message, cb);
});
chainpad.onPatch(function () {
onRemote({ realtime: chainpad });
});
var myID; var myID;
var isReady = false; var isReady = false;
var evConnected = Util.mkEvent(true); var evConnected = Util.mkEvent(true);
@ -67,33 +81,20 @@ define([
sframeChan.on('EV_RT_DISCONNECT', function () { sframeChan.on('EV_RT_DISCONNECT', function () {
isReady = false; isReady = false;
if (chainpad) { chainpad.abort(); } chainpad.abort();
onConnectionChange({ state: false }); onConnectionChange({ state: false });
}); });
sframeChan.on('EV_RT_CONNECT', function (content) { sframeChan.on('EV_RT_CONNECT', function (content) {
//content.members.forEach(userList.onJoin); //content.members.forEach(userList.onJoin);
myID = content.myID;
isReady = false; isReady = false;
if (chainpad) { if (myID) {
// it's a reconnect // it's a reconnect
if (chainpad) { chainpad.start(); } myID = content.myID;
chainpad.start();
onConnectionChange({ state: true, myId: myID }); onConnectionChange({ state: true, myId: myID });
return; return;
} }
chainpad = ChainPad.create({ myID = content.myID;
userName: userName,
initialState: initialState,
transformFunction: transformFunction,
validateContent: validateContent,
avgSyncMilliseconds: avgSyncMilliseconds,
logLevel: logLevel
});
chainpad.onMessage(function(message, cb) {
sframeChan.query('Q_RT_MESSAGE', message, cb);
});
chainpad.onPatch(function () {
onRemote({ realtime: chainpad });
});
onInit({ onInit({
myID: myID, myID: myID,
realtime: chainpad, realtime: chainpad,
@ -130,7 +131,8 @@ define([
getMyID: function () { return myID; }, getMyID: function () { return myID; },
metadataMgr: metadataMgr, metadataMgr: metadataMgr,
whenRealtimeSyncs: whenRealtimeSyncs, whenRealtimeSyncs: whenRealtimeSyncs,
onInfiniteSpinner: evInfiniteSpinner.reg onInfiniteSpinner: evInfiniteSpinner.reg,
chainpad: chainpad,
}); });
}; };
return Object.freeze(module.exports); return Object.freeze(module.exports);

Loading…
Cancel
Save