Fix back button in teams with messenger and drive

pull/1/head
yflory 5 years ago
parent 5e58f7db4c
commit fc2938a27e

@ -524,6 +524,7 @@ define([
var edPublic = priv.edPublic; var edPublic = priv.edPublic;
APP.origin = priv.origin; APP.origin = priv.origin;
APP.hideDuplicateOwned = Util.find(priv, ['settings', 'drive', 'hideDuplicate']); APP.hideDuplicateOwned = Util.find(priv, ['settings', 'drive', 'hideDuplicate']);
APP.closed = false;
var updateObject = driveConfig.updateObject; var updateObject = driveConfig.updateObject;
var updateSharedFolders = driveConfig.updateSharedFolders; var updateSharedFolders = driveConfig.updateSharedFolders;

@ -122,7 +122,7 @@ define([
}); });
}; };
var onReady = function (ctx, id, lm, keys, cId, cb) { var onReady = function (ctx, id, lm, roster, keys, cId, cb) {
var proxy = lm.proxy; var proxy = lm.proxy;
var team = { var team = {
id: id, id: id,
@ -292,7 +292,7 @@ define([
}; };
var rosterData = keys.roster || {}; var rosterData = keys.roster || {};
var rosterKeys = rosterData.edit ? Crypto.Team.deriveMemberKeys(rosterData.edit, myKeys) var rosterKeys = rosterData.edit ? Crypto.Team.deriveMemberKeys(rosterData.edit, myKeys)
: Crypto.Team.deriveGuestKeys(rosterData.view); : Crypto.Team.deriveGuestKeys(rosterData.view || '');
Roster.create({ Roster.create({
network: ctx.store.network, network: ctx.store.network,
channel: rosterKeys.channel, channel: rosterKeys.channel,
@ -385,7 +385,7 @@ define([
noChainPad: true, noChainPad: true,
crypto: crypto, crypto: crypto,
metadata: { metadata: {
validateKey: secret.keys.validateKey, validateKey: chatSecret.keys.validateKey,
owners: [ctx.store.proxy.edPublic], owners: [ctx.store.proxy.edPublic],
} }
}; };
@ -469,6 +469,10 @@ define([
ctx.onReadyHandlers[teamId].splice(idx, 1); ctx.onReadyHandlers[teamId].splice(idx, 1);
} }
}); });
// And leave the channel channel
try {
ctx.store.messenger.removeClient(cId);
} catch (e) {}
if (!id) { return void cb(); } if (!id) { return void cb(); }
// If the team is loading, as ourselves in the list // If the team is loading, as ourselves in the list
@ -549,8 +553,8 @@ define([
var t = {}; var t = {};
Object.keys(teams).forEach(function (id) { Object.keys(teams).forEach(function (id) {
t[id] = { t[id] = {
name: teams[id].name, name: teams[id].metadata.name,
edPublic: Util.find(teams[id], ['keys', 'edPublic']) edPublic: Util.find(teams[id], ['keys', 'drive', 'edPublic'])
}; };
}); });
return t; return t;

@ -167,11 +167,10 @@ define([
// Universal direct channel // Universal direct channel
var modules = {}; var modules = {};
funcs.makeUniversal = function (type, cfg) { funcs.makeUniversal = function (type, cfg) {
if (modules[type]) { return; }
var sframeChan = funcs.getSframeChannel();
modules[type] = { modules[type] = {
onEvent: cfg.onEvent || function () {} onEvent: cfg.onEvent || function () {}
}; };
var sframeChan = funcs.getSframeChannel();
return { return {
execCommand: function (cmd, data, cb) { execCommand: function (cmd, data, cb) {
sframeChan.query("Q_UNIVERSAL_COMMAND", { sframeChan.query("Q_UNIVERSAL_COMMAND", {

@ -191,13 +191,10 @@ define([
// Team APP // Team APP
var loadTeam = function (common, id, firstLoad) { var loadTeam = function (common, id) {
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var proxy = {}; var proxy = {};
var folders = {}; var folders = {};
if (firstLoad) {
buildUI(common, true);
}
nThen(function (waitFor) { nThen(function (waitFor) {
updateObject(sframeChan, proxy, waitFor(function () { updateObject(sframeChan, proxy, waitFor(function () {
updateSharedFolders(sframeChan, null, proxy.drive, folders, waitFor()); updateSharedFolders(sframeChan, null, proxy.drive, folders, waitFor());
@ -256,7 +253,7 @@ define([
var team = obj[id]; var team = obj[id];
var a = h('a', 'Open'); var a = h('a', 'Open');
lis.push(h('li', h('ul', [ lis.push(h('li', h('ul', [
h('li', 'Name: ' + team.name), // XXX h('li', 'Name: ' + team.metadata.name), // XXX
h('li', 'ID: ' + id), // XXX h('li', 'ID: ' + id), // XXX
h('li', a) // XXX h('li', a) // XXX
]))); ])));
@ -341,7 +338,6 @@ define([
APP.module.execCommand('OPEN_TEAM_CHAT', { APP.module.execCommand('OPEN_TEAM_CHAT', {
teamId: APP.team teamId: APP.team
}, function (obj) { }, function (obj) {
console.warn(obj);
if (obj && obj.error) { if (obj && obj.error) {
return void UI.alert(Messages.error); // XXX return void UI.alert(Messages.error); // XXX
} }
@ -431,11 +427,7 @@ define([
}); });
$('body').css('display', ''); $('body').css('display', '');
if (privateData.teamId) { loadMain(common);
loadTeam(common, privateData.teamId, true);
} else {
loadMain(common);
}
var onDisconnect = function (noAlert) { var onDisconnect = function (noAlert) {

Loading…
Cancel
Save