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

This commit is contained in:
smizrahi
2023-06-20 09:04:01 +02:00
parent 8baa770681
commit eb42e1787c
2 changed files with 9 additions and 1 deletions

View File

@@ -833,6 +833,7 @@
{
// This additional identity should not appear in the identity manager of the Preferences
[identity setObject: [NSNumber numberWithBool: YES] forKey: @"isReadOnly"];
[identity setObject: [NSNumber numberWithBool: NO] forKey: @"isDefault"];
}
[identities addObject: identity];
}

View File

@@ -1348,6 +1348,7 @@ static NSArray *reminderValues = nil;
NSMutableArray *previousIdentities, *newIdentities;
NSMutableDictionary *identity, *newIdentitiesAsDict;
int i;
BOOL isDefault;
if ([account isKindOfClass: [NSDictionary class]])
{
@@ -1372,9 +1373,15 @@ static NSArray *reminderValues = nil;
// Remove existing deleted identities
for (identity in [user allIdentities]) {
// 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"]]
&& [previousIdentities count] > 1
&& ![identity boolForKey:@"isDefault"]) {
&& !isDefault) {
[previousIdentities removeObjectAtIndex: i];
i--;
}