diff --git a/UI/Contacts/UIxListEditor.m b/UI/Contacts/UIxListEditor.m index 666f69037..618054f51 100644 --- a/UI/Contacts/UIxListEditor.m +++ b/UI/Contacts/UIxListEditor.m @@ -1,6 +1,6 @@ /* UIxListEditor.m - this file is part of SOGo * - * Copyright (C) 2008-2020 Inverse inc. + * Copyright (C) 2008-2022 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ */ +#import + +#import + #import #import #import @@ -27,6 +31,7 @@ #import #import +#import #import #import @@ -166,8 +171,9 @@ - (void) setReferences: (NSArray *) references { + NSAutoreleasePool *pool; NSDictionary *values; - NSArray *initialReferences, *emails; + NSArray *initialReferences, *refs, *emails; NSDictionary *currentReference; NSString *uid, *workMail, *fn, *newUID; int i, count; @@ -179,10 +185,12 @@ // Remove from the list the cards that were deleted initialReferences = [list cardReferences]; count = [initialReferences count]; + refs = [references objectsForKey: @"id" + notFoundMarker: [NSNull null]]; for (i = 0; i < count; i++) { cardReference = [initialReferences objectAtIndex: i]; - if (![references containsObject: [cardReference reference]]) + if (![refs containsObject: [cardReference reference]]) [list deleteCardReference: cardReference]; } @@ -190,6 +198,7 @@ // Add new cards count = [references count]; + pool = [[NSAutoreleasePool alloc] init]; for (i = 0; i < count; i++) { @@ -249,6 +258,11 @@ } } } + if (i > 0 && i % 10 == 0) + { + [pool release]; + pool = [[NSAutoreleasePool alloc] init]; + } } } diff --git a/UI/WebServerResources/js/Contacts/AddressBookController.js b/UI/WebServerResources/js/Contacts/AddressBookController.js index 57ffed1e1..6492cbb95 100644 --- a/UI/WebServerResources/js/Contacts/AddressBookController.js +++ b/UI/WebServerResources/js/Contacts/AddressBookController.js @@ -427,8 +427,9 @@ }; this.newListWithSelectedCards = function() { + var _this = this; var selectedCards = _.filter(this.selectedFolder.$cards, function(card) { return card.selected; }); - var promises = [], refs = []; + var promises = [], ids = [], refs = []; _.forEach(selectedCards, function(card) { if (card.$isList({expandable: true})) { @@ -451,8 +452,17 @@ else if (card.$$email && card.$$email.length) { refs.push(card); } + else if (!card.$loaded) { + refs.push(card); + ids.push(card.id); + } }); + if (ids.length) { + var futureHeadersData = AddressBook.$$resource.post(this.selectedFolder.id, 'headers', {ids: ids}); + promises.push(_this.selectedFolder.$unwrapHeaders(futureHeadersData)); + } + $q.all(promises).then(function() { refs = _.uniqBy(_.map(refs, function(o) { return { reference: o.id || o.reference, email: o.$$email || o.email };