From e5deffe21f37954446b9e33f491497a9e65f25ce Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 8 Oct 2019 11:10:03 +0200 Subject: [PATCH] Fix team deletion --- www/common/common-ui-elements.js | 10 ++++++++-- www/common/outer/async-store.js | 2 +- www/common/outer/team.js | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index b13353d0e..d1e5a87b3 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1343,7 +1343,6 @@ define([ }]; var content = h('div', [ - h('h4', 'Invite friends to your team: '+ team.name), list.div ]); @@ -4020,8 +4019,15 @@ define([ module.execCommand('JOIN_TEAM', { team: msg.content.team }, 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); + if (priv.app !== 'teams') { common.openURL('/teams/'); } }); return; } diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 9ff329335..a80ca9f9c 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -679,7 +679,7 @@ define([ give(); 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) { if (otherOwners) { diff --git a/www/common/outer/team.js b/www/common/outer/team.js index ef5960121..d99f169d3 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -562,6 +562,7 @@ define([ if (!me || me.role !== "OWNER") { return cb({ error: "EFORBIDDEN"}); } var edPublic = Util.find(ctx, ['store', 'proxy', 'edPublic']); + var teamEdPublic = Util.find(teamData, ['keys', 'drive', 'edPublic']); nThen(function (waitFor) { ctx.Store.anonRpcMsg(null, { @@ -597,18 +598,24 @@ define([ msg: 'GET_METADATA', data: c }, _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 isOwner = md && Array.isArray(md.owners) && md.owners.indexOf(edPublic) !== -1; - if (!isOwner) { return void _w.abort(); } - otherOwners = md.owners.some(function (ed) { return void ed !== edPublic; }); + var isOwner = md && Array.isArray(md.owners) && md.owners.indexOf(teamEdPublic) !== -1; + if (!isOwner) { + give(); + return void _w.abort(); + } + otherOwners = md.owners.some(function (ed) { return ed !== teamEdPublic; }); })); }).nThen(function (_w) { if (otherOwners) { ctx.Store.setPadMetadata(null, { channel: c, command: 'RM_OWNERS', - value: [edPublic], + value: [teamEdPublic], }, _w()); return; }