Preparations for the Team refactoring

pull/1/head
yflory 5 years ago
parent fd7567188b
commit a2edf5be64

@ -43,6 +43,31 @@ define([
modules: {} modules: {}
}; };
var getProxy = function (teamId) {
if (!teamId) { return store.proxy; }
try {
var teams = store.modules['team'];
var team = teams.getTeam(teamId);
if (team) { return; }
return team.proxy;
} catch (e) {
console.error(e);
return;
}
};
var getManager = function (teamId) {
if (!teamId) { return store.manager; }
try {
var teams = store.modules['team'];
var team = teams.getTeam(teamId);
if (team) { return; }
return team.manager;
} catch (e) {
console.error(e);
return;
}
};
var onSync = function (cb) { var onSync = function (cb) {
nThen(function (waitFor) { nThen(function (waitFor) {
Realtime.whenRealtimeSyncs(store.realtime, waitFor()); Realtime.whenRealtimeSyncs(store.realtime, waitFor());

@ -3,10 +3,15 @@ define([
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-constants.js', '/common/common-constants.js',
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/outer/sharedfolder.js',
'/bower_components/chainpad-listmap/chainpad-listmap.js', '/bower_components/chainpad-listmap/chainpad-listmap.js',
'/bower_components/chainpad-crypto/crypto.js', '/bower_components/chainpad-crypto/crypto.js',
'/bower_components/chainpad/chainpad.dist.js', '/bower_components/chainpad/chainpad.dist.js',
], function (Util, Hash, Constants, Realtime, Listmap, Crypto, ChainPad) { ], function (Util, Hash, Constants, Realtime,
SF,
Listmap, Crypto, ChainPad) {
var Team = {}; var Team = {};
var initializeTeams = function (ctx, cb) { var initializeTeams = function (ctx, cb) {
@ -14,6 +19,13 @@ define([
cb(); cb();
}; };
var onready = function (ctx, team, id, cb) {
// XXX
// load manager
// load shared folders
};
var openChannel = function (ctx, team, id, cb) { var openChannel = function (ctx, team, id, cb) {
// XXX team password? // XXX team password?
var secret = Hash.getSecrets('team', team.href); var secret = Hash.getSecrets('team', team.href);
@ -35,9 +47,13 @@ define([
lm.proxy.on('create', function () { lm.proxy.on('create', function () {
}).on('ready', function () { }).on('ready', function () {
ctx.teams[id] = { ctx.teams[id] = {
proxy: lm.proxy,
listmap: lm, listmap: lm,
clients: [] clients: []
}; };
onReady(ctx, team, id, function () {
// TODO
});
if (ctx.onReadyHandlers.length) { if (ctx.onReadyHandlers.length) {
ctx.onReadyHandlers.forEach(function (f) { ctx.onReadyHandlers.forEach(function (f) {
try { try {
@ -101,6 +117,9 @@ define([
}); });
}); });
team.getTeam = function (id) {
return ctx.teams[id];
};
team.removeClient = function (clientId) { team.removeClient = function (clientId) {
removeClient(ctx, clientId); removeClient(ctx, clientId);
}; };

Loading…
Cancel
Save