diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index d0a84816a..f53a6b496 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -81,8 +81,8 @@ define([ }); localStorage.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs; } - var cache = {}; - var localStore = {}; + var cache = window.cpCache = {}; + var localStore = window.localStore = {}; Object.keys(localStorage).forEach(function (k) { if (k.indexOf('CRYPTPAD_CACHE|') === 0) { cache[k.slice(('CRYPTPAD_CACHE|').length)] = localStorage[k]; diff --git a/www/filepicker/main.js b/www/filepicker/main.js index d6017c2dd..cada394ba 100644 --- a/www/filepicker/main.js +++ b/www/filepicker/main.js @@ -58,7 +58,7 @@ define([ // Remove the listener once we've received the READY message window.removeEventListener('message', whenReady); // Answer with the requested data - postMsg(JSON.stringify({ txid: data.txid, language: Cryptpad.getLanguage() })); + postMsg(JSON.stringify({ txid: data.txid, language: Cryptpad.getLanguage(), localStore: window.localStore, cache: window.cpCache })); // Then start the channel window.addEventListener('message', function (msg) { diff --git a/www/share/main.js b/www/share/main.js index 43e514f58..28cc1a882 100644 --- a/www/share/main.js +++ b/www/share/main.js @@ -60,7 +60,7 @@ define([ // Remove the listener once we've received the READY message window.removeEventListener('message', whenReady); // Answer with the requested data - postMsg(JSON.stringify({ txid: data.txid, language: Cryptpad.getLanguage() })); + postMsg(JSON.stringify({ txid: data.txid, language: Cryptpad.getLanguage(), localStore: window.localStore, cache: window.cpCache })); // Then start the channel window.addEventListener('message', function (msg) { @@ -105,6 +105,21 @@ define([ config.addCommonRpc(sframeChan); + sframeChan.on('EV_CACHE_PUT', function (x) { + Object.keys(x).forEach(function (k) { + localStorage['CRYPTPAD_CACHE|' + k] = x[k]; + }); + }); + sframeChan.on('EV_LOCALSTORE_PUT', function (x) { + Object.keys(x).forEach(function (k) { + if (typeof(x[k]) === "undefined") { + delete localStorage['CRYPTPAD_STORE|' + k]; + return; + } + localStorage['CRYPTPAD_STORE|' + k] = x[k]; + }); + }); + sframeChan.on('Q_GET_FILES_LIST', function (types, cb) { Cryptpad.getSecureFilesList(types, function (err, data) { cb({