Fix team deletion

pull/1/head
yflory 5 years ago
parent 75b3c99d04
commit 3015d7f22b

@ -1343,7 +1343,6 @@ define([
}]; }];
var content = h('div', [ var content = h('div', [
h('h4', 'Invite friends to your team: '+ team.name),
list.div list.div
]); ]);
@ -4020,8 +4019,15 @@ define([
module.execCommand('JOIN_TEAM', { module.execCommand('JOIN_TEAM', {
team: msg.content.team team: msg.content.team
}, function (obj) { }, function (obj) {
if (obj && obj.error) { return void UI.warn(Messages.error); } if (obj && obj.error) {
if (obj.error === 'ENOENT') {
common.mailbox.dismiss(data, function () {});
return void UI.alert(Messages.deletedError);
}
return void UI.warn(Messages.error);
}
answer(true); answer(true);
if (priv.app !== 'teams') { common.openURL('/teams/'); }
}); });
return; return;
} }

@ -678,7 +678,7 @@ define([
give(); give();
return void _w.abort(); return void _w.abort();
} }
otherOwners = md.owners.some(function (ed) { return void ed !== edPublic; }); otherOwners = md.owners.some(function (ed) { return ed !== edPublic; });
})); }));
}).nThen(function (_w) { }).nThen(function (_w) {
if (otherOwners) { if (otherOwners) {

@ -568,6 +568,7 @@ define([
if (!me || me.role !== "OWNER") { return cb({ error: "EFORBIDDEN"}); } if (!me || me.role !== "OWNER") { return cb({ error: "EFORBIDDEN"}); }
var edPublic = Util.find(ctx, ['store', 'proxy', 'edPublic']); var edPublic = Util.find(ctx, ['store', 'proxy', 'edPublic']);
var teamEdPublic = Util.find(teamData, ['keys', 'drive', 'edPublic']);
nThen(function (waitFor) { nThen(function (waitFor) {
ctx.Store.anonRpcMsg(null, { ctx.Store.anonRpcMsg(null, {
@ -603,18 +604,24 @@ define([
msg: 'GET_METADATA', msg: 'GET_METADATA',
data: c data: c
}, _w(function (obj) { }, _w(function (obj) {
if (obj && obj.error) { return void _w.abort(); } if (obj && obj.error) {
give();
return void _w.abort();
}
var md = obj[0]; var md = obj[0];
var isOwner = md && Array.isArray(md.owners) && md.owners.indexOf(edPublic) !== -1; var isOwner = md && Array.isArray(md.owners) && md.owners.indexOf(teamEdPublic) !== -1;
if (!isOwner) { return void _w.abort(); } if (!isOwner) {
otherOwners = md.owners.some(function (ed) { return void ed !== edPublic; }); give();
return void _w.abort();
}
otherOwners = md.owners.some(function (ed) { return ed !== teamEdPublic; });
})); }));
}).nThen(function (_w) { }).nThen(function (_w) {
if (otherOwners) { if (otherOwners) {
ctx.Store.setPadMetadata(null, { ctx.Store.setPadMetadata(null, {
channel: c, channel: c,
command: 'RM_OWNERS', command: 'RM_OWNERS',
value: [edPublic], value: [teamEdPublic],
}, _w()); }, _w());
return; return;
} }

Loading…
Cancel
Save