|
|
@ -49,29 +49,31 @@ define([
|
|
|
|
store.manager.addProxy(id, sf.rt.proxy, leave);
|
|
|
|
store.manager.addProxy(id, sf.rt.proxy, leave);
|
|
|
|
cb(sf.rt, sf.metadata);
|
|
|
|
cb(sf.rt, sf.metadata);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
sf.teams.push(store);
|
|
|
|
sf.teams.push({
|
|
|
|
|
|
|
|
cb: cb,
|
|
|
|
|
|
|
|
store: store,
|
|
|
|
|
|
|
|
id: id
|
|
|
|
|
|
|
|
});
|
|
|
|
if (handler) { handler(id, sf.rt); }
|
|
|
|
if (handler) { handler(id, sf.rt); }
|
|
|
|
return sf.rt;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sf && sf.queue && sf.rt) {
|
|
|
|
if (sf && !sf.ready && sf.rt) {
|
|
|
|
// The shared folder is loading, add our callbacks to the queue
|
|
|
|
// The shared folder is loading, add our callbacks to the queue
|
|
|
|
sf.queue.push({
|
|
|
|
sf.teams.push({
|
|
|
|
cb: cb,
|
|
|
|
cb: cb,
|
|
|
|
store: store,
|
|
|
|
store: store,
|
|
|
|
id: id
|
|
|
|
id: id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
sf.teams.push(store);
|
|
|
|
|
|
|
|
if (handler) { handler(id, sf.rt); }
|
|
|
|
if (handler) { handler(id, sf.rt); }
|
|
|
|
return sf.rt;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sf = allSharedFolders[secret.channel] = {
|
|
|
|
sf = allSharedFolders[secret.channel] = {
|
|
|
|
queue: [{
|
|
|
|
teams: [{
|
|
|
|
cb: cb,
|
|
|
|
cb: cb,
|
|
|
|
store: store,
|
|
|
|
store: store,
|
|
|
|
id: id
|
|
|
|
id: id
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
teams: [store]
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var owners = data.owners;
|
|
|
|
var owners = data.owners;
|
|
|
@ -92,25 +94,27 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var rt = sf.rt = Listmap.create(listmapConfig);
|
|
|
|
var rt = sf.rt = Listmap.create(listmapConfig);
|
|
|
|
rt.proxy.on('ready', function (info) {
|
|
|
|
rt.proxy.on('ready', function (info) {
|
|
|
|
if (!sf.queue) {
|
|
|
|
if (!sf.teams) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sf.queue.forEach(function (obj) {
|
|
|
|
sf.teams.forEach(function (obj) {
|
|
|
|
var leave = function () { SF.leave(secret.channel, teamId); };
|
|
|
|
var leave = function () { SF.leave(secret.channel, teamId); };
|
|
|
|
obj.store.manager.addProxy(obj.id, rt.proxy, leave);
|
|
|
|
obj.store.manager.addProxy(obj.id, rt.proxy, leave);
|
|
|
|
obj.cb(rt, info.metadata);
|
|
|
|
obj.cb(rt, info.metadata);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
sf.metadata = info.metadata;
|
|
|
|
sf.metadata = info.metadata;
|
|
|
|
sf.ready = true;
|
|
|
|
sf.ready = true;
|
|
|
|
delete sf.queue;
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
rt.proxy.on('error', function (info) {
|
|
|
|
rt.proxy.on('error', function (info) {
|
|
|
|
if (info && info.error) {
|
|
|
|
if (info && info.error) {
|
|
|
|
if (info.error === "EDELETED" ) {
|
|
|
|
if (info.error === "EDELETED" ) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Deprecate the shared folder from each team
|
|
|
|
// Deprecate the shared folder from each team
|
|
|
|
sf.teams.forEach(function (store) {
|
|
|
|
// XXX We can't deprecate a read-only proxy: the read-only seed will change...
|
|
|
|
store.manager.deprecateProxy(id, secret.channel);
|
|
|
|
// We can only remove it
|
|
|
|
|
|
|
|
sf.teams.forEach(function (obj) {
|
|
|
|
|
|
|
|
console.log(obj.store.id, obj.store, obj.id);
|
|
|
|
|
|
|
|
obj.store.manager.deprecateProxy(obj.id, secret.channel);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} catch (e) {}
|
|
|
|
} catch (e) {}
|
|
|
|
delete allSharedFolders[secret.channel];
|
|
|
|
delete allSharedFolders[secret.channel];
|
|
|
@ -128,8 +132,8 @@ define([
|
|
|
|
var clients = sf.teams;
|
|
|
|
var clients = sf.teams;
|
|
|
|
if (!Array.isArray(clients)) { return; }
|
|
|
|
if (!Array.isArray(clients)) { return; }
|
|
|
|
var idx;
|
|
|
|
var idx;
|
|
|
|
clients.some(function (store, i) {
|
|
|
|
clients.some(function (obj, i) {
|
|
|
|
if (store.id === teamId) {
|
|
|
|
if (obj.store.id === teamId) {
|
|
|
|
idx = i;
|
|
|
|
idx = i;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -145,6 +149,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the password locally
|
|
|
|
SF.updatePassword = function (Store, data, network, cb) {
|
|
|
|
SF.updatePassword = function (Store, data, network, cb) {
|
|
|
|
var oldChannel = data.oldChannel;
|
|
|
|
var oldChannel = data.oldChannel;
|
|
|
|
var href = data.href;
|
|
|
|
var href = data.href;
|
|
|
@ -157,13 +162,18 @@ define([
|
|
|
|
sf.rt.stop();
|
|
|
|
sf.rt.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var nt = nThen;
|
|
|
|
var nt = nThen;
|
|
|
|
sf.teams.forEach(function (s) {
|
|
|
|
sf.teams.forEach(function (obj) {
|
|
|
|
|
|
|
|
// XXX if we're a viewer in this team, we can't update the keys
|
|
|
|
nt = nt(function (waitFor) {
|
|
|
|
nt = nt(function (waitFor) {
|
|
|
|
var sfId = s.manager.user.userObject.getSFIdFromHref(href);
|
|
|
|
var s = obj.store;
|
|
|
|
|
|
|
|
var sfId = obj.id;
|
|
|
|
var shared = Util.find(s.proxy, ['drive', UserObject.SHARED_FOLDERS]) || {};
|
|
|
|
var shared = Util.find(s.proxy, ['drive', UserObject.SHARED_FOLDERS]) || {};
|
|
|
|
if (!sfId || !shared[sfId]) { return; }
|
|
|
|
if (!sfId || !shared[sfId]) { return; }
|
|
|
|
var sf = JSON.parse(JSON.stringify(shared[sfId]));
|
|
|
|
var sf = JSON.parse(JSON.stringify(shared[sfId]));
|
|
|
|
sf.password = password;
|
|
|
|
sf.password = password;
|
|
|
|
|
|
|
|
sf.channel = secret.channel;
|
|
|
|
|
|
|
|
sf.href = '/drive/#'+Hash.getEditHashFromKeys(secret); // XXX encrypt
|
|
|
|
|
|
|
|
sf.roHref = '/drive/#'+Hash.getViewHashFromKeys(secret);
|
|
|
|
SF.load({
|
|
|
|
SF.load({
|
|
|
|
network: network,
|
|
|
|
network: network,
|
|
|
|
store: s,
|
|
|
|
store: s,
|
|
|
|