diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 22f54f17d..e19b59a9e 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -254,8 +254,8 @@ define([ postMessage("REMOVE_OWNED_CHANNEL", channel, cb); }; - common.getDeletedPads = function (cb) { - postMessage("GET_DELETED_PADS", null, function (obj) { + common.getDeletedPads = function (data, cb) { + postMessage("GET_DELETED_PADS", data, function (obj) { if (obj && obj.error) { return void cb(obj.error); } cb(null, obj); }); diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index 189507676..6711efb2b 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -48,14 +48,6 @@ define([ }); }; - var loadFullHistory = function (config, common, cb) { - var realtime = createRealtime(config); - common.getFullHistory(realtime, function () { - cb(null, realtime); - }); - }; - loadFullHistory = loadFullHistory; - var fillChainPad = function (realtime, messages) { messages.forEach(function (m) { realtime.message(m); diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 085d928a2..dd3f7a8c9 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -514,11 +514,22 @@ define([ channel: secret.channel, validateKey: secret.keys.validateKey }, function (encryptedMsgs) { - cb(encryptedMsgs.map(function (msg) { - // The 3rd parameter "true" means we're going to skip signature validation. - // We don't need it since the message is already validated serverside by hk - return crypto.decrypt(msg, true, true); - })); + var nt = nThen; + var decryptedMsgs = []; + var total = encryptedMsgs.length; + encryptedMsgs.forEach(function (msg, i) { + nt = nt(function (waitFor) { + // The 3rd parameter "true" means we're going to skip signature validation. + // We don't need it since the message is already validated serverside by hk + decryptedMsgs.push(crypto.decrypt(msg, true, true)); + setTimeout(waitFor(function () { + sframeChan.event('EV_FULL_HISTORY_STATUS', (i+1)/total); + }), 5); + }).nThen; + }); + nt(function () { + cb(decryptedMsgs); + }); }); }); sframeChan.on('Q_GET_HISTORY_RANGE', function (data, cb) { @@ -590,6 +601,13 @@ define([ }); }); + sframeChan.on('Q_DRIVE_GETDELETED', function (data, cb) { + Cryptpad.getDeletedPads(data, function (err, obj) { + if (err) { return void console.error(err); } + cb(obj); + }); + }); + sframeChan.on('Q_SESSIONSTORAGE_PUT', function (data, cb) { sessionStorage[data.key] = data.value; cb(); diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 5f4c1bdea..8a3353133 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -302,17 +302,6 @@ define([ }); }; - funcs.getFullHistory = function (realtime, cb) { - ctx.sframeChan.query('Q_GET_FULL_HISTORY', null, function (err, messages) { - if (err) { return void console.error(err); } - if (!Array.isArray(messages)) { return; } - messages.forEach(function (m) { - realtime.message(m); - }); - cb(); - }); - }; - // href is optional here: if not provided, we use the href of the current tab funcs.getPadAttribute = function (key, cb, href) { ctx.sframeChan.query('Q_GET_PAD_ATTRIBUTE', { diff --git a/www/debug/app-debug.less b/www/debug/app-debug.less index d1651642d..7962dfd97 100644 --- a/www/debug/app-debug.less +++ b/www/debug/app-debug.less @@ -15,10 +15,38 @@ display: flex; min-height: 0; } - #cp-app-debug-content { + #cp-app-debug-content, #cp-app-debug-history { flex: 1; overflow: auto; white-space: pre-wrap; + display: none; + } + #cp-app-debug-content { + flex-flow: column; + align-items: center; + justify-content: center; + .cp-app-debug-content { + flex: 1; + min-height: 0; + } + .cp-app-debug-progress { + width: 80%; + } + .cp-loading-progress-bar { + position: relative; + border: 1px solid #eee; + height: 36px; + } + #cp-app-debug-progres-bar-text { + position: absolute; + width: 100%; + text-align: center; + height: 100%; + line-height: 36px; + } + #cp-app-debug-loading { + text-align: center; + } } } diff --git a/www/debug/inner.html b/www/debug/inner.html index 201863d1c..2ac53948c 100644 --- a/www/debug/inner.html +++ b/www/debug/inner.html @@ -13,6 +13,7 @@
+
diff --git a/www/debug/inner.js b/www/debug/inner.js index 70ce3f0de..ecd66bda7 100644 --- a/www/debug/inner.js +++ b/www/debug/inner.js @@ -8,6 +8,7 @@ define([ '/common/sframe-common.js', '/common/common-interface.js', '/common/common-hash.js', + '/common/common-constants.js', '/common/hyperscript.js', '/api/config', '/common/common-realtime.js', @@ -30,6 +31,7 @@ define([ SFCommon, UI, Hash, + Constants, h, ApiConfig, CommonRealtime, @@ -62,13 +64,149 @@ define([ var readOnly = true; var sframeChan = common.getSframeChannel(); - var getGraph = function (cb) { - var chainpad = ChainWalk.create({ - userName: 'debug', - initialState: '', - logLevel: 0, - noPrune: true + var getHrefsTable = function (chainpad, length, cb, progress) { + var priv = metadataMgr.getPrivateData(); + var edPublic = priv.edPublic; + + var pads = {}; + var isOwned = function (data) { + data = data || {}; + return data && data.owners && Array.isArray(data.owners) && data.owners.indexOf(edPublic) !== -1; + }; + var parseBlock = function (block) { + var c = block.getContent().doc; + if (!c) { return void console.error(block); } + var p; + try { + p = JSON.parse(c).drive || {}; + } catch (e) { + console.error(e); + p = {}; + } + + // Get pads from the old storage key + var old = p[Constants.oldStorageKey]; + var ids = p[Constants.storageKey]; + var pad, parsed, chan, href; + if (old && Array.isArray(old)) { + for (var i = 0; i