Skip to content

Commit

Permalink
Fix losing accounts after restart
Browse files Browse the repository at this point in the history
  • Loading branch information
poetwang committed Dec 6, 2016
1 parent 275c425 commit 3fac634
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Pod/Classes/SeafConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ - (void)clearAccount
{
[SeafGlobal.sharedObject removeObjectForKey:_address];
[SeafGlobal.sharedObject removeObjectForKey:[NSString stringWithFormat:@"%@/%@", _address, self.username]];
[SeafGlobal.sharedObject removeObjectForKey:[NSString stringWithFormat:@"%@/%@/settings", _address, self.username]];

NSString *path = [self certPathForHost:[self host]];
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
[SeafAvatar clearCache];
Expand All @@ -568,16 +570,11 @@ - (void)getAccountInfo:(void (^)(bool result))handler
^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSDictionary *account = JSON;
Debug("account detail:%@", account);
NSString *oldUsername = self.username;
NSString *newUsername = [account objectForKey:@"email"];
[Utils dict:_info setObject:[account objectForKey:@"total"] forKey:@"total"];
[Utils dict:_info setObject:[account objectForKey:@"total"] forKey:@"total"];
[Utils dict:_info setObject:[account objectForKey:@"email"] forKey:@"email"];
[Utils dict:_info setObject:[account objectForKey:@"usage"] forKey:@"usage"];
[Utils dict:_info setObject:[account objectForKey:@"name"] forKey:@"name"];
[Utils dict:_info setObject:_address forKey:@"link"];
if (![oldUsername isEqualToString:newUsername]) {
[SeafGlobal.sharedObject removeObjectForKey:[NSString stringWithFormat:@"%@/%@", _address, self.username]];
[Utils dict:_info setObject:newUsername forKey:@"username"];
}
[self saveAccountInfo];
if (handler) handler(true);
}
Expand Down

0 comments on commit 3fac634

Please sign in to comment.