1. implement cryptpadCache which has put() and get() functions that can be used like a localStorage that auto-flushes when a new version is released

2. change loading.js to use packaged css in order to get the loading screen up as quick as possible.
3. change LessLoader to cache less in cryptpadCache
This commit is contained in:
Caleb James DeLisle
2017-09-14 10:23:05 +02:00
parent 710418f42f
commit 8a32b72ffc
7 changed files with 127 additions and 37 deletions

View File

@@ -34,12 +34,34 @@ define([
Crypto = _Crypto;
Cryptget = _Cryptget;
FilePicker = _FilePicker;
if (localStorage.CRYPTPAD_URLARGS !== ApiConfig.requireConf.urlArgs) {
console.log("New version, flushing cache");
Object.keys(localStorage).forEach(function (k) {
if (k.indexOf('CRYPTPAD_CACHE|') !== 0) { return; }
delete localStorage[k];
});
localStorage.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs;
}
var cache = {};
Object.keys(localStorage).forEach(function (k) {
if (k.indexOf('CRYPTPAD_CACHE|') !== 0) { return; }
cache[k.slice(('CRYPTPAD_CACHE|').length)] = localStorage[k];
});
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
sframeChan = sfc;
}));
}), false, { cache: cache });
Cryptpad.ready(waitFor());
}));
}).nThen(function (waitFor) {
sframeChan.on('EV_CACHE_PUT', function (x) {
Object.keys(x).forEach(function (k) {
localStorage['CRYPTPAD_CACHE|' + k] = x[k];
});
});
secret = Cryptpad.getSecrets();
if (!secret.channel) {
// New pad: create a new random channel id