diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 1faab92f8..56c3de5dd 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -1808,10 +1808,13 @@ define([ //var data = cmdData.data; var s = getStore(cmdData.teamId); var cb2 = function (data2) { - var send = cmdData.teamId ? s.sendEvent : sendDriveEvent; - send('DRIVE_CHANGE', { - path: ['drive', UserObject.FILES_DATA] - }, clientId); + + getAllStores().forEach(function (_s) { + var send = _s.id ? _s.sendEvent : sendDriveEvent; + send('DRIVE_CHANGE', { + path: ['drive', UserObject.FILES_DATA] + }, clientId); + }); onSync(cmdData.teamId, function () { cb(data2); }); diff --git a/www/common/outer/sharedfolder.js b/www/common/outer/sharedfolder.js index b6ef17f7c..1c8e23c4e 100644 --- a/www/common/outer/sharedfolder.js +++ b/www/common/outer/sharedfolder.js @@ -16,14 +16,46 @@ define([ - config: network and "manager" (either the user one or a team manager) - id: shared folder id */ + + var allSharedFolders = {}; + SF.load = function (config, id, data, cb) { var network = config.network; var store = config.store; - var manager = store.manager; var handler = store.handleSharedFolder; var parsed = Hash.parsePadUrl(data.href); var secret = Hash.getSecrets('drive', parsed.hash, data.password); + + var sf = allSharedFolders[secret.channel]; + if (sf && sf.ready && sf.rt) { + // The shared folder is already loaded, return its data + setTimeout(function () { + store.manager.addProxy(id, sf.rt.proxy, sf.leave); + cb(sf.rt, sf.metadata); + }); + if (handler) { handler(id, sf.rt); } + return sf.rt; + } + if (sf && sf.queue && sf.rt) { + // The shared folder is loading, add our callbacks to the queue + sf.queue.push({ + cb: cb, + store: store, + id: id + }); + if (handler) { handler(id, sf.rt); } + return sf.rt; + } + + sf = allSharedFolders[secret.channel] = { + queue: [{ + cb: cb, + store: store, + id: id + }] + }; + var owners = data.owners; var listmapConfig = { data: {}, @@ -40,10 +72,19 @@ define([ owners: owners } }; - var rt = Listmap.create(listmapConfig); + var rt = sf.rt = Listmap.create(listmapConfig); rt.proxy.on('ready', function (info) { - manager.addProxy(id, rt.proxy, info.leave); - cb(rt, info.metadata); + if (!sf.queue) { + return; + } + sf.queue.forEach(function (obj) { + obj.store.manager.addProxy(obj.id, rt.proxy, info.leave); + obj.cb(rt, info.metadata); + }); + sf.leave = info.leave; + sf.metadata = info.metadata; + sf.ready = true; + delete sf.queue; }); if (handler) { handler(id, rt); } return rt; diff --git a/www/common/outer/team.js b/www/common/outer/team.js index af232d01d..ef5960121 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -211,7 +211,9 @@ define([ SF.load({ network: ctx.store.network, store: team - }, id, data, cb); + }, id, data, function (id, rt) { + cb(id, rt); + }); }; var manager = team.manager = ProxyManager.create(proxy.drive, { onSync: function (cb) { ctx.Store.onSync(id, cb); }, diff --git a/www/teams/inner.js b/www/teams/inner.js index 918f0eeac..7e7b18c24 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -382,20 +382,14 @@ define([ var name = $(input).val(); if (!name.trim()) { return; } state = true; - UI.confirm('Are you sure?', function (yes) { - if (!yes) { + APP.module.execCommand('CREATE_TEAM', { + name: name + }, function () { + var $div = $('div.cp-team-list').empty(); + refreshList(common, function (content) { state = false; - return; - } - APP.module.execCommand('CREATE_TEAM', { - name: name - }, function () { - var $div = $('div.cp-team-list').empty(); - refreshList(common, function (content) { - state = false; - $div.append(content); - $('div.cp-team-cat-list').click(); - }); + $div.append(content); + $('div.cp-team-cat-list').click(); }); }); });