Skip to content

Commit

Permalink
linagora#180 fixed duplicate addressbooks showing up when an adressbo…
Browse files Browse the repository at this point in the history
…ok is publicly shared and delegated to a user
  • Loading branch information
rezk2ll committed Dec 10, 2021
1 parent 93672f3 commit a90338b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/linagora.esn.contact/app/sidebar/sidebar.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,23 @@ function ContactSidebarController(
var categories = contactAddressbookDisplayService.categorizeDisplayShells(self.displayShells);

self.userAddressbooks = categories.userAddressbooks;
self.sharedAddressbooks = categories.sharedAddressbooks;
self.sharedAddressbooks = _getUniqueSharedAddressbooks(categories.sharedAddressbooks);
self.virtualAddressbooks = categories.virtualAddressbooks;
}

function _getUniqueSharedAddressbooks(addressbooks) {
if (!addressbooks) return;

const uniqueAddressbookList = addressbooks.reduce((acc, current) => {
const { source: { href } } = current.shell;

if (!acc[href]) {
acc[href] = current;
}

return acc;
}, {});

return Object.values(uniqueAddressbookList);
}
}

0 comments on commit a90338b

Please sign in to comment.