From d19cf861a02295c67412fc54cbcc1cb3228c0a6b Mon Sep 17 00:00:00 2001 From: giomfo Date: Fri, 13 Apr 2018 20:14:44 +0200 Subject: [PATCH] Bug Fix - Crash on URL like https://riot.im/#/app/register?hs_url=... Fix here the crash Another commit will be done to prevent logging out on unexpected register url https://github.com/vector-im/riot-ios/issues/1838 --- Riot/AppDelegate.m | 20 +++++++++++--------- Riot/ViewController/SettingsViewController.m | 5 +++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Riot/AppDelegate.m b/Riot/AppDelegate.m index f8a79e326..3069cccd0 100644 --- a/Riot/AppDelegate.m +++ b/Riot/AppDelegate.m @@ -2587,15 +2587,17 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN #endif // Logout all matrix account - [[MXKAccountManager sharedManager] logout]; - - // Return to authentication screen - [_masterTabBarController showAuthenticationScreen]; - - // Note: Keep App settings - - // Reset the contact manager - [[MXKContactManager sharedManager] reset]; + [[MXKAccountManager sharedManager] logoutWithCompletion:^{ + + // Return to authentication screen + [_masterTabBarController showAuthenticationScreen]; + + // Note: Keep App settings + + // Reset the contact manager + [[MXKContactManager sharedManager] reset]; + + }]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context diff --git a/Riot/ViewController/SettingsViewController.m b/Riot/ViewController/SettingsViewController.m index d196e052d..4ae577344 100644 --- a/Riot/ViewController/SettingsViewController.m +++ b/Riot/ViewController/SettingsViewController.m @@ -1,6 +1,7 @@ /* Copyright 2015 OpenMarket Ltd Copyright 2017 Vector Creations Ltd + Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -2606,7 +2607,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - [[MXKAccountManager sharedManager] logout]; + [[MXKAccountManager sharedManager] logoutWithCompletion:nil]; }); } @@ -2930,7 +2931,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - [[MXKAccountManager sharedManager] logout]; + [[MXKAccountManager sharedManager] logoutWithCompletion:nil]; }); }