Merge pull request #1895 from vector-im/fix_account_deactivation_completion

Fix account deactivation completion
This commit is contained in:
SBiOSoftWhare 2018-06-01 16:19:51 +02:00 committed by GitHub
commit 1fe6e98b94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 7 deletions

View file

@ -117,9 +117,12 @@ extern NSString *const kAppDelegateNetworkStatusDidChangeNotification;
Log out all the accounts without confirmation.
Show the authentication screen on successful logout.
@param sendLogoutRequest Indicate whether send logout request to home server.
@param completion the block to execute at the end of the operation.
*/
- (void)logoutWithCompletion:(void (^)(BOOL isLoggedOut))completion;
- (void)logoutSendingRequestServer:(BOOL)sendLogoutServerRequest
completion:(void (^)(BOOL isLoggedOut))completion;
#pragma mark - Matrix Accounts handling

View file

@ -2677,7 +2677,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
[topVC startActivityIndicator];
}
[self logoutWithCompletion:^(BOOL isLoggedOut) {
[self logoutSendingRequestServer:YES completion:^(BOOL isLoggedOut) {
if (completion)
{
completion (YES);
@ -2685,7 +2685,8 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
}];
}
- (void)logoutWithCompletion:(void (^)(BOOL isLoggedOut))completion
- (void)logoutSendingRequestServer:(BOOL)sendLogoutServerRequest
completion:(void (^)(BOOL isLoggedOut))completion
{
self.pushRegistry = nil;
isPushRegistered = NO;

View file

@ -203,7 +203,7 @@ static CGFloat const kTextFontSize = 15.0;
- (void)enableUserActions:(BOOL)enableUserActions
{
self.navigationItem.rightBarButtonItem.enabled = enableUserActions;
self.forgetMessageButton.enabled = enableUserActions;
self.forgetMessageButton.userInteractionEnabled = enableUserActions;
self.deactivateAcccountButton.enabled = enableUserActions;
}
@ -272,8 +272,15 @@ static CGFloat const kTextFontSize = 15.0;
[self.mainSession deactivateAccountWithAuthParameters:authParameters eraseAccount:eraseAllMessages success:^{
NSLog(@"[SettingsViewController] Deactivate account with success");
[weakSelf stopActivityIndicator];
[weakSelf enableUserActions:YES];
typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf)
{
[strongSelf stopActivityIndicator];
[strongSelf enableUserActions:YES];
[strongSelf.delegate deactivateAccountViewControllerDidDeactivateWithSuccess:strongSelf];
}
} failure:^(NSError *error) {
NSLog(@"[SettingsViewController] Failed to deactivate account");

View file

@ -4102,8 +4102,9 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
- (void)deactivateAccountViewControllerDidDeactivateWithSuccess:(DeactivateAccountViewController *)deactivateAccountViewController
{
NSLog(@"[SettingsViewController] Deactivate account with success");
[[AppDelegate theDelegate] logoutWithCompletion:^(BOOL isLoggedOut) {
[[AppDelegate theDelegate] logoutSendingRequestServer:NO completion:^(BOOL isLoggedOut) {
NSLog(@"[SettingsViewController] Complete clear user data after account deactivation");
}];
}