mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 21:26:57 +02:00
Remove duplicated logout code and fix spinner.
- Remove some duplication of logout behaviour - Fix additional spinner on homeViewController
This commit is contained in:
@@ -1372,9 +1372,9 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
else
|
||||
{
|
||||
void(^findRoom)(void) = ^{
|
||||
if ([_masterTabBarController.selectedViewController isKindOfClass:MXKActivityHandlingViewController.class])
|
||||
if ([_masterTabBarController.selectedViewController conformsToProtocol:@protocol(MXKViewControllerActivityHandling)])
|
||||
{
|
||||
MXKActivityHandlingViewController *homeViewController = (MXKActivityHandlingViewController*)_masterTabBarController.selectedViewController;
|
||||
UIViewController<MXKViewControllerActivityHandling> *homeViewController = (UIViewController<MXKViewControllerActivityHandling>*)_masterTabBarController.selectedViewController;
|
||||
|
||||
[homeViewController startActivityIndicator];
|
||||
|
||||
@@ -1651,11 +1651,13 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||
// Try to get more information about the room before opening its preview
|
||||
[roomPreviewData peekInRoom:^(BOOL succeeded) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
MXKViewController *homeViewController = (MXKViewController*)self.masterTabBarController.selectedViewController;
|
||||
|
||||
// Note: the activity indicator will not disappear if the session is not ready
|
||||
[homeViewController stopActivityIndicator];
|
||||
if ([self.masterTabBarController.selectedViewController conformsToProtocol:@protocol(MXKViewControllerActivityHandling)])
|
||||
{
|
||||
UIViewController<MXKViewControllerActivityHandling> *homeViewController = (UIViewController<MXKViewControllerActivityHandling>*)self.masterTabBarController.selectedViewController;
|
||||
|
||||
// Note: the activity indicator will not disappear if the session is not ready
|
||||
[homeViewController stopActivityIndicator];
|
||||
}
|
||||
|
||||
// If no data is available for this room, we name it with the known room alias (if any).
|
||||
if (!succeeded && self->universalLinkFragmentPendingRoomAlias[roomIdOrAlias])
|
||||
|
||||
+20
-2
@@ -16,8 +16,8 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class HomeViewControllerWithBannerWrapperViewController: MXKActivityHandlingViewController, BannerPresentationProtocol {
|
||||
|
||||
class HomeViewControllerWithBannerWrapperViewController: UIViewController, MXKViewControllerActivityHandling, BannerPresentationProtocol {
|
||||
|
||||
@objc let homeViewController: HomeViewController
|
||||
private var bannerContainerView: UIView!
|
||||
private var stackView: UIStackView!
|
||||
@@ -85,4 +85,22 @@ class HomeViewControllerWithBannerWrapperViewController: MXKActivityHandlingView
|
||||
bannerView.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - MXKViewControllerActivityHandling
|
||||
var activityIndicator: UIActivityIndicatorView! {
|
||||
get {
|
||||
return homeViewController.activityIndicator
|
||||
}
|
||||
set {
|
||||
homeViewController.activityIndicator = newValue
|
||||
}
|
||||
}
|
||||
|
||||
func startActivityIndicator() {
|
||||
homeViewController.startActivityIndicator()
|
||||
}
|
||||
|
||||
func stopActivityIndicator() {
|
||||
homeViewController.stopActivityIndicator()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1453,7 +1453,7 @@
|
||||
return NO;
|
||||
} andPersistentTokenDataHandler:^(void (^handler)(NSArray<MXCredentials *> *credentials, void (^completion)(BOOL didUpdateCredentials))) {
|
||||
[[MXKAccountManager sharedManager] readAndWriteCredentials:handler];
|
||||
}];
|
||||
} andUnauthenticatedHandler: nil];
|
||||
|
||||
MXWeakify(self);
|
||||
[[MXKAccountManager sharedManager].dehydrationService rehydrateDeviceWithMatrixRestClient:mxRestClient dehydrationKey:keyData success:^(NSString * deviceId) {
|
||||
|
||||
@@ -359,4 +359,8 @@ typedef BOOL (^MXKAccountOnCertificateChange)(MXKAccount *mxAccount, NSData *cer
|
||||
success:(void (^)(void))success
|
||||
failure:(void (^)(NSError *error))failure;
|
||||
|
||||
/**
|
||||
Handle unauthenticated errors from the server triggering hard/soft logouts as appropriate.
|
||||
*/
|
||||
- (void)handleUnauthenticated:(MXError *)error andCompletion:(void (^)(void))completion;
|
||||
@end
|
||||
|
||||
@@ -959,9 +959,6 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
- (void)deletePusher
|
||||
{
|
||||
if (self.pushNotificationServiceIsActive)
|
||||
@@ -1670,16 +1667,6 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
||||
{
|
||||
isPauseRequested = NO;
|
||||
}
|
||||
else if (mxSession.state == MXSessionStateUnauthenticated)
|
||||
{
|
||||
// Logout this account
|
||||
[[MXKAccountManager sharedManager] removeAccount:self sendLogoutRequest:NO completion:nil];
|
||||
}
|
||||
else if (mxSession.state == MXSessionStateSoftLogout)
|
||||
{
|
||||
// Soft logout this account
|
||||
[[MXKAccountManager sharedManager] softLogout:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)prepareRESTClient
|
||||
@@ -1688,9 +1675,9 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MXWeakify(self);
|
||||
mxRestClient = [[MXRestClient alloc] initWithCredentials:self.mxCredentials andOnUnrecognizedCertificateBlock:^BOOL(NSData *certificate) {
|
||||
|
||||
MXStrongifyAndReturnValueIfNil(self, NO);
|
||||
if (_onCertificateChangeBlock)
|
||||
{
|
||||
if (_onCertificateChangeBlock (self, certificate))
|
||||
@@ -1713,9 +1700,29 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
||||
|
||||
} andPersistentTokenDataHandler:^(void (^handler)(NSArray<MXCredentials *> *credentials, void (^completion)(BOOL didUpdateCredentials))) {
|
||||
[MXKAccountManager.sharedManager readAndWriteCredentials:handler];
|
||||
} andUnauthenticatedHandler:^(MXError *error, void (^completion)(void)) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self handleUnauthenticated:error andCompletion:completion];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (void)handleUnauthenticated:(MXError *)error andCompletion:(void (^)(void))completion
|
||||
{
|
||||
if (error.httpResponse.statusCode == 401
|
||||
&& [error.userInfo[kMXErrorSoftLogoutKey] isEqual:@(YES)])
|
||||
{
|
||||
MXLogDebug(@"[MXKAccountManager] handleUnauthenticated: soft logout.");
|
||||
[[MXKAccountManager sharedManager] softLogout:self];
|
||||
completion();
|
||||
}
|
||||
else
|
||||
{
|
||||
MXLogDebug(@"[MXKAccountManager] handleUnauthenticated: hard logout.");
|
||||
[[MXKAccountManager sharedManager] removeAccount:self sendLogoutRequest:NO completion:completion];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onDateTimeFormatUpdate
|
||||
{
|
||||
if ([mxSession.roomSummaryUpdateDelegate isKindOfClass:MXKEventFormatter.class])
|
||||
|
||||
Reference in New Issue
Block a user