Preparations for the Team refactoring

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

@ -43,6 +43,31 @@ define([
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) {
nThen(function (waitFor) {
Realtime.whenRealtimeSyncs(store.realtime, waitFor());

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

Loading…
Cancel
Save