Fix duplicate team bug

pull/1/head
yflory 4 years ago
parent ae92614289
commit 01a8e45307

@ -736,14 +736,20 @@ define([
UI.proposal = function (content, cb) {
var clicked = false;
var buttons = [{
name: Messages.friendRequest_later,
onClick: function () {},
onClick: function () {
if (clicked) { return; }
clicked = true;
},
keys: [27]
}, {
className: 'primary',
name: Messages.friendRequest_accept,
onClick: function () {
if (clicked) { return; }
clicked = true;
cb(true);
},
keys: [13]
@ -751,6 +757,8 @@ define([
className: 'primary',
name: Messages.friendRequest_decline,
onClick: function () {
if (clicked) { return; }
clicked = true;
cb(false);
},
keys: [[13, 'ctrl']]

@ -1668,7 +1668,33 @@ define([
updateMyRights(ctx, p[1]);
});
// Remove duplicate teams
var _teams = {};
Object.keys(teams).forEach(function (id) {
var t = teams[id];
var _t = _teams[t.channel];
// Not found yet? add to the list
if (!_t) {
_teams[t.channel] = { edit: Boolean(t.hash), id:id };
return;
}
// Team already found. If this one has better access rights, keep it.
// Otherwise, delete it
// No edit right or we already have edit rights? delete
if (!t.hash || _t.edit) {
delete teams[id];
return;
}
// We didn't have edit rights and now we have them: replace
delete teams[_t.id];
_teams[t.channel] = { edit: Boolean(t.hash), id:id };
});
// Load teams
Object.keys(teams).forEach(function (id) {
ctx.onReadyHandlers[id] = [];
if (!Util.find(teams, [id, 'keys', 'mailbox'])) {

Loading…
Cancel
Save