fix(preferences): Fix NSException issue when SOGoCreateIdentitiesDisabled is set

This commit is contained in:
smizrahi committed 2023-06-20 22:25:12 +02:00
1 parent 8baa770681
commit eb42e1787c
2 files changed
+9 -1

No files matched your search

+1
View File
@@ -833,6 +833,7 @@
{ {
// This additional identity should not appear in the identity manager of the Preferences // This additional identity should not appear in the identity manager of the Preferences
[identity setObject: [NSNumber numberWithBool: YES] forKey: @"isReadOnly"]; [identity setObject: [NSNumber numberWithBool: YES] forKey: @"isReadOnly"];
[identity setObject: [NSNumber numberWithBool: NO] forKey: @"isDefault"];
} }
[identities addObject: identity]; [identities addObject: identity];
} }
+8 -1
View File
@@ -1348,6 +1348,7 @@ static NSArray *reminderValues = nil;
NSMutableArray *previousIdentities, *newIdentities; NSMutableArray *previousIdentities, *newIdentities;
NSMutableDictionary *identity, *newIdentitiesAsDict; NSMutableDictionary *identity, *newIdentitiesAsDict;
int i; int i;
BOOL isDefault;
if ([account isKindOfClass: [NSDictionary class]]) if ([account isKindOfClass: [NSDictionary class]])
{ {
@@ -1372,9 +1373,15 @@ static NSArray *reminderValues = nil;
// Remove existing deleted identities // Remove existing deleted identities
for (identity in [user allIdentities]) { for (identity in [user allIdentities]) {
// Identity deleted and at least one identity and not the default identity // Identity deleted and at least one identity and not the default identity
if ([identity objectForKey:@"isDefault"]) {
isDefault = [[identity objectForKey:@"isDefault"] boolValue];
} else {
isDefault = NO;
}
if (![newIdentitiesAsDict objectForKey: [identity objectForKey:@"email"]] if (![newIdentitiesAsDict objectForKey: [identity objectForKey:@"email"]]
&& [previousIdentities count] > 1 && [previousIdentities count] > 1
&& ![identity boolForKey:@"isDefault"]) { && !isDefault) {
[previousIdentities removeObjectAtIndex: i]; [previousIdentities removeObjectAtIndex: i];
i--; i--;
} }