Fix cache and storage issues in share and filepicker iframes

pull/1/head
yflory 5 years ago
parent 73af078e4a
commit d02092eb76

@ -81,8 +81,8 @@ define([
}); });
localStorage.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs; localStorage.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs;
} }
var cache = {}; var cache = window.cpCache = {};
var localStore = {}; var localStore = window.localStore = {};
Object.keys(localStorage).forEach(function (k) { Object.keys(localStorage).forEach(function (k) {
if (k.indexOf('CRYPTPAD_CACHE|') === 0) { if (k.indexOf('CRYPTPAD_CACHE|') === 0) {
cache[k.slice(('CRYPTPAD_CACHE|').length)] = localStorage[k]; cache[k.slice(('CRYPTPAD_CACHE|').length)] = localStorage[k];

@ -58,7 +58,7 @@ define([
// Remove the listener once we've received the READY message // Remove the listener once we've received the READY message
window.removeEventListener('message', whenReady); window.removeEventListener('message', whenReady);
// Answer with the requested data // 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 // Then start the channel
window.addEventListener('message', function (msg) { window.addEventListener('message', function (msg) {

@ -60,7 +60,7 @@ define([
// Remove the listener once we've received the READY message // Remove the listener once we've received the READY message
window.removeEventListener('message', whenReady); window.removeEventListener('message', whenReady);
// Answer with the requested data // 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 // Then start the channel
window.addEventListener('message', function (msg) { window.addEventListener('message', function (msg) {
@ -105,6 +105,21 @@ define([
config.addCommonRpc(sframeChan); 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) { sframeChan.on('Q_GET_FILES_LIST', function (types, cb) {
Cryptpad.getSecureFilesList(types, function (err, data) { Cryptpad.getSecureFilesList(types, function (err, data) {
cb({ cb({

Loading…
Cancel
Save