From 49766d006f1de0695abc0dc26a4fed0c5a5bc6bb Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 25 Oct 2019 17:40:31 +0200 Subject: [PATCH] Fix deprecated shared folder in read-only team --- www/common/cryptpad-common.js | 1 - www/common/drive-ui.js | 13 +++++++++++-- www/common/proxy-manager.js | 6 +++--- www/teams/inner.js | 8 ++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 9e9e0495a..9ed46ce04 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1524,7 +1524,6 @@ define([ var noSharedWorker = false; if (localStorage.CryptPad_noWorkers) { noWorker = localStorage.CryptPad_noWorkers === '1'; - noWorker = true; console.error('WebWorker/SharedWorker state forced to ' + !noWorker); } Nthen(function (waitFor2) { diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 476cc0996..2e43ec5e7 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1798,6 +1798,11 @@ define([ if (!manager.isFile(element)) { return; } var data = manager.getFileData(element); + + if (!Object.keys(data).length) { + return true; + } + var href = data.href || data.roHref; if (!data) { return void logError("No data for the file", element); } @@ -1958,10 +1963,14 @@ define([ if (isTrash) { return; } openFile(root[key]); }); + var invalid; if (isFolder) { - addFolderData(element, key, $element); + invalid = addFolderData(element, key, $element); } else { - addFileData(element, $element); + invalid = addFileData(element, $element); + } + if (invalid) { + return; } $element.addClass(liClass); var droppable = !isTrash && !APP.$content.data('readOnlyFolder'); diff --git a/www/common/proxy-manager.js b/www/common/proxy-manager.js index 977aeaf6d..db0d6a258 100644 --- a/www/common/proxy-manager.js +++ b/www/common/proxy-manager.js @@ -54,9 +54,9 @@ define([ var deprecateProxy = function (Env, id, channel) { if (Env.user.userObject.readOnly) { // In a read-only team, we can't deprecate a shared folder - if (Env.folders[id]) { - Env.folders[id].proxy = { deprecated: true }; - } + // Use a empty object with a deprecated flag... + var lm = { proxy: { deprecated: true } }; + addProxy(Env, id, lm, function () {}); return void Env.Store.refreshDriveUI(); } if (channel) { Env.unpinPads([channel], function () {}); } diff --git a/www/teams/inner.js b/www/teams/inner.js index ffbd26f32..6a0f87c48 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -61,6 +61,14 @@ define([ sframeChan.query('Q_DRIVE_GETOBJECT', { sharedFolder: fId }, waitFor(function (err, newObj) { + if (newObj && newObj.deprecated) { + delete folders[fId]; + delete drive.sharedFolders[fId]; + if (manager && manager.folders) { + delete manager.folders[fId]; + } + return; + } folders[fId] = folders[fId] || {}; copyObjectValue(folders[fId], newObj); folders[fId].readOnly = !secret.keys.secondaryKey;