(fix) b0rk3n sort saving regarding the asc/desc state

This commit is contained in:
Ludovic Marcotte
2015-08-14 15:11:07 -04:00
parent 8f75bdce2d
commit ffa4079fa8
2 changed files with 24 additions and 19 deletions
+20 -16
View File
@@ -1,5 +1,5 @@
/* /*
Copyright (C) 2006-2014 Inverse inc. Copyright (C) 2006-2015 Inverse inc.
This file is part of SOGo. This file is part of SOGo.
@@ -39,6 +39,7 @@
#import <Contacts/SOGoContactFolder.h> #import <Contacts/SOGoContactFolder.h>
#import <Contacts/SOGoContactFolders.h> #import <Contacts/SOGoContactFolders.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserSettings.h> #import <SOGo/SOGoUserSettings.h>
#import <NGCards/NGVCard.h> #import <NGCards/NGVCard.h>
@@ -83,32 +84,33 @@
s = [rq formValueForKey: @"sort"]; s = [rq formValueForKey: @"sort"];
if (![s length]) if (![s length])
s = [self defaultSortKey]; s = [self defaultSortKey];
else
[self saveSortValue: s];
return s; return s;
} }
- (void) saveSortValue: (NSString *) sort - (void) saveSortValue
{ {
NSString *ascending;
SOGoUserSettings *us;
NSMutableDictionary *contactSettings; NSMutableDictionary *contactSettings;
NSString *ascending, *sort;
SOGoUserSettings *us;
sort = [[context request] formValueForKey: @"sort"];
ascending = [[context request] formValueForKey: @"asc"]; ascending = [[context request] formValueForKey: @"asc"];
if ([sort length]) if ([sort length])
{
us = [[context activeUser] userSettings];
contactSettings = [us objectForKey: @"Contact"];
// Must create if it doesn't exist
if (!contactSettings)
{ {
contactSettings = [NSMutableDictionary dictionary]; us = [[context activeUser] userSettings];
[us setObject: contactSettings forKey: @"Contact"]; 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 intValue]], nil]
forKey: @"SortingState"];
[us synchronize];
} }
[contactSettings setObject: [NSArray arrayWithObjects: [sort lowercaseString], [NSString stringWithFormat: @"%d", (ascending?1:0)], nil] forKey: @"SortingState"];
[us synchronize];
}
} }
- (NSArray *) contactInfos - (NSArray *) contactInfos
@@ -123,6 +125,8 @@
WORequest *rq; WORequest *rq;
unsigned int i; unsigned int i;
[self saveSortValue];
if (!contactInfos) if (!contactInfos)
{ {
folder = [self clientObject]; folder = [self clientObject];
+2 -1
View File
@@ -695,7 +695,8 @@ static NSArray *tasksFields = nil;
calendarSettings = [NSMutableDictionary dictionary]; calendarSettings = [NSMutableDictionary dictionary];
[us setObject: calendarSettings forKey: @"Calendar"]; [us setObject: calendarSettings forKey: @"Calendar"];
} }
[calendarSettings setObject: [NSArray arrayWithObjects: [sort lowercaseString], [NSString stringWithFormat: @"%d", (ascending?1:0)], nil] forKey: submodule]; [calendarSettings setObject: [NSArray arrayWithObjects: [sort lowercaseString], [NSString stringWithFormat: @"%d", [ascending intValue]], nil]
forKey: submodule];
[us synchronize]; [us synchronize];
} }
} }