diff --git a/customize.dist/loading.js b/customize.dist/loading.js index 5b916a0e5..a335a8903 100644 --- a/customize.dist/loading.js +++ b/customize.dist/loading.js @@ -279,7 +279,7 @@ button:not(.btn).primary:hover{ var built = false; var types = ['less', 'drive', 'migrate', 'sf', 'team', 'pad', 'end']; - var current; + var current, progress; var makeList = function (data) { var c = types.indexOf(data.type); current = c; @@ -295,7 +295,7 @@ button:not(.btn).primary:hover{ }; var list = ''; @@ -303,7 +303,7 @@ button:not(.btn).primary:hover{ }; var makeBar = function (data) { var c = types.indexOf(data.type); - var l = types.length; + var l = types.length - 1; // don't count "end" as a type var progress = Math.min(data.progress, 100); var p = (progress / l) + (100 * c / l); var bar = '
'+ @@ -315,8 +315,13 @@ button:not(.btn).primary:hover{ var hasErrored = false; var updateLoadingProgress = function (data) { if (!built || !data) { return; } + + // Make sure progress doesn't go backward var c = types.indexOf(data.type); if (c < current) { return console.error(data); } + if (c === current && progress > data.progress) { return console.error(data); } + progress = data.progress; + try { document.querySelector('.cp-loading-spinner-container').style.display = 'none'; document.querySelector('.cp-loading-progress-list').innerHTML = makeList(data); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 9f88e85a9..714598ca4 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -701,7 +701,7 @@ define([ }); }; - common.useFile = function (Crypt, cb, optsPut) { + common.useFile = function (Crypt, cb, optsPut, onProgress) { var fileHost = Config.fileHost || window.location.origin; var data = common.fromFileData; var parsed = Hash.parsePadUrl(data.href); @@ -758,7 +758,9 @@ define([ return void cb(err); } u8 = _u8; - })); + }), function (progress) { + onProgress(progress * 50); + }); }).nThen(function (waitFor) { require(["/file/file-crypto.js"], waitFor(function (FileCrypto) { FileCrypto.decrypt(u8, key, waitFor(function (err, _res) { @@ -767,7 +769,9 @@ define([ return void cb(err); } res = _res; - })); + }), function (progress) { + onProgress(50 + progress * 50); + }); })); }).nThen(function (waitFor) { var ext = Util.parseFilename(data.title).ext; diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index d17924cf0..768ca4db2 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -1802,7 +1802,12 @@ define([ } startRealtime(); cb(); - }, cryptputCfg); + }, cryptputCfg, function (progress) { + sframeChan.event('EV_LOADING_INFO', { + type: 'pad', + progress: progress + }); + }); return; } // Start realtime outside the iframe and callback