From b33225e2d7030bb26488990487028c5b0a682af9 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 7 Jan 2021 16:00:51 +0100 Subject: [PATCH] Fix safe links for pads stored in teams --- www/common/cryptpad-common.js | 4 +++- www/common/outer/async-store.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index b96accd28..d047c4d4b 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -964,9 +964,11 @@ define([ // Get data about a given channel: use with hidden hashes common.getPadDataFromChannel = function (obj, cb) { if (!obj || !obj.channel) { return void cb('EINVAL'); } + // Note: no timeout for this command, we may only have loaded the cached drive + // and need to wait for the fully synced drive postMessage("GET_PAD_DATA_FROM_CHANNEL", obj, function (data) { cb(void 0, data); - }); + }, {timeout: -1}); }; diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 7e1dad783..f4fa534bb 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1268,8 +1268,17 @@ define([ } }); }); + var result = res || viewRes; + + // If we're not fully synced yet and we don't have a result, wait for the ready event + if (!result && store.offline) { + onReadyEvt.reg(function () { + Store.getPadDataFromChannel(clientId, obj, cb); + }); + return; + } // Call back with the best value we can get - cb(res || viewRes || {}); + cb(result || {}); }; // Hidden hash: if a pad is deleted, we may have to switch back to full hash