Skip to content

Commit

Permalink
Merge pull request #99 from inverse-inc/feature/saveSortContacts
Browse files Browse the repository at this point in the history
Added sort saving to Contacts
  • Loading branch information
extrafu committed Aug 13, 2015
2 parents 02daebe + 8fb5c1d commit d3d9a72
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions UI/Contacts/UIxContactsListActions.m
Expand Up @@ -39,6 +39,8 @@
#import <Contacts/SOGoContactFolder.h>
#import <Contacts/SOGoContactFolders.h>

#import <SOGo/SOGoUserSettings.h>

#import <NGCards/NGVCard.h>
#import <NGCards/NGVList.h>
#import <SoObjects/Contacts/SOGoContactGCSEntry.h>
Expand Down Expand Up @@ -81,10 +83,34 @@ - (NSString *) sortKey
s = [rq formValueForKey: @"sort"];
if (![s length])
s = [self defaultSortKey];
else
[self saveSortValue: s];

return s;
}

- (void) saveSortValue: (NSString *) sort
{
NSString *ascending;
SOGoUserSettings *us;
NSMutableDictionary *contactSettings;

ascending = [[context request] formValueForKey: @"asc"];
if ([sort length])
{
us = [[context activeUser] userSettings];
contactSettings = [us objectForKey: @"Contact"];
// Must create if it doesn't exist
if (!contactSettings)
{
contactSettings = [NSMutableDictionary dictionary];
[us setObject: contactSettings forKey: @"Contact"];
}
[contactSettings setObject: [NSArray arrayWithObjects: [sort lowercaseString], [NSString stringWithFormat: @"%d", (ascending?1:0)], nil] forKey: @"SortingState"];
[us synchronize];
}
}

- (NSArray *) contactInfos
{
id <SOGoContactFolder> folder;
Expand Down

0 comments on commit d3d9a72

Please sign in to comment.