From 1edfbadf4eab1d7cafe91d673a55df92b989394a Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 25 Feb 2021 18:31:44 +0100 Subject: [PATCH] Fix invisible restricted shared folders in teams --- www/common/outer/async-store.js | 9 ++++++++- www/common/proxy-manager.js | 4 +++- www/drive/inner.js | 2 +- www/teams/inner.js | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index eadf88079..3ceafa7cd 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1624,6 +1624,7 @@ define([ })) {} var auth = function () { + if (!_store) { return void cb('ERESTRICTED'); } var rpc = _store.rpc; if (!rpc) { return void cb('ERESTRICTED'); } rpc.send('COOKIE', '', function (err) { @@ -1632,7 +1633,7 @@ define([ }; // Wait for the RPC we need to be ready and then tyr to authenticate - if (_store.onRpcReadyEvt) { + if (_store && _store.onRpcReadyEvt) { _store.onRpcReadyEvt.reg(function () { auth(); }); @@ -2851,6 +2852,12 @@ define([ drive[Constants.oldStorageKey] = []; } // Drive already exist: return the existing drive, don't load data from legacy store + if (store.manager) { + // If a cache is loading, make sure it is complete before calling onReady + return void onCacheReadyEvt.reg(function () { + onReady(clientId, returned, cb); + }); + } onReady(clientId, returned, cb); }) .on('change', ['drive', 'migrate'], function () { diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index a7a4abe6f..7093f0ec5 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -17,7 +17,7 @@ define([ // Add a shared folder to the list var addProxy = function (Env, id, lm, leave, editKey, force) { - if (Env.folders[id] && !force) { + if (Env.folders[id] && !force && !Env.folders[id].restricted) { // Shared folder already added to the proxy-manager, probably // a cached version if (Env.folders[id].offline && !lm.cache) { @@ -26,6 +26,7 @@ define([ } return; } + if (Env.folders[id]) { console.warn(Env.folders[id]); } var cfg = getConfig(Env); cfg.sharedFolder = true; cfg.id = id; @@ -48,6 +49,7 @@ define([ proxy: lm.proxy, userObject: userObject, leave: leave, + restricted: proxy.restricted, offline: Boolean(lm.cache) }; if (proxy.on) { diff --git a/www/drive/inner.js b/www/drive/inner.js index 0feb3d755..577d45210 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -42,7 +42,7 @@ define([ if (!drive || !drive.sharedFolders) { return void cb(); } - var r = drive.restrictedFolders = drive.restrictedFolders || {}; + var r = drive.restrictedFolders = {}; var oldIds = Object.keys(folders); nThen(function (waitFor) { Object.keys(drive.sharedFolders).forEach(function (fId) { diff --git a/www/teams/inner.js b/www/teams/inner.js index 1caa95711..0b2d6ec85 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -61,7 +61,7 @@ define([ if (!drive || !drive.sharedFolders) { return void cb(); } - var r = drive.restrictedFolders = drive.restrictedFolders || {}; + var r = drive.restrictedFolders = {}; var oldIds = Object.keys(folders); nThen(function (waitFor) { Object.keys(drive.sharedFolders).forEach(function (fId) { @@ -76,7 +76,7 @@ define([ r[fId] = drive.sharedFolders[fId]; if (!r[fId].title) { r[fId].title = r[fId].lastTitle; } } - if (newObj && (newObj.deprecated || newObj.restricted)) { + if (newObj && (newObj.deprecated /*|| newObj.restricted*/)) { delete folders[fId]; delete drive.sharedFolders[fId]; if (manager && manager.folders) {