diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 77fded8fa..579cb9ba9 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -67,6 +67,8 @@ define([ modules: {} }; + Store.onReadyEvt = onReadyEvt; + var getStore = function (teamId) { if (!teamId) { return store; } try { @@ -2243,6 +2245,7 @@ define([ isNew: isNew, network: store.network || store.networkPromise, store: s, + Store: Store, isNewChannel: Store.isNewChannel }, id, data, cb); }; diff --git a/www/common/outer/sharedfolder.js b/www/common/outer/sharedfolder.js index 7ae165e0b..35956b5ca 100644 --- a/www/common/outer/sharedfolder.js +++ b/www/common/outer/sharedfolder.js @@ -164,6 +164,16 @@ define([ readOnly: !Boolean(secondaryKey) }; + // If there is an allow list and we're offline, try again when we're synced + var onRejected = function (allowed, _cb) { + var cb = Util.once(Util.mkAsync(_cb)); + if (store.offline && config.Store) { + config.Store.onReadyEvt.reg(cb); + return; + } + cb('ERESTRICTED'); + }; + var owners = data.owners; var listmapConfig = { data: {}, @@ -179,7 +189,8 @@ define([ metadata: { validateKey: secret.keys.validateKey || undefined, owners: owners - } + }, + onRejected: onRejected }; var rt = sf.rt = Listmap.create(listmapConfig); rt.proxy.on('cacheready', function () { @@ -246,8 +257,6 @@ define([ return void cb(); } if (info.error === "ERESTRICTED" ) { - // This shouldn't happen: allow list are disabled for shared folders - // but call "cb" to make sure we won't block the initial "waitFor" sf.teams.forEach(function (obj) { obj.store.manager.restrictedProxy(obj.id, secret.channel); }); @@ -326,6 +335,7 @@ define([ network: network, store: s, updatePassword: true, + Store: Store, isNewChannel: Store.isNewChannel }, sfId, sf, waitFor()); if (!s.rpc) { return; } @@ -356,6 +366,7 @@ define([ SF.load({ network: network, store: store, + Store: Store, isNewChannel: Store.isNewChannel }, id, sf, waitFor(function () { progress({ diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 70d5acfcd..2efc574af 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -280,6 +280,7 @@ define([ isNew: isNew, network: ctx.store.network, store: team, + Store: ctx.Store, isNewChannel: ctx.Store.isNewChannel }, id, data, cb); };