Feature/4976 fix for blocking behaviour

This commit is contained in:
Frank Rotermund
2023-08-23 15:13:16 +00:00
parent 632889901a
commit 15ca136b4e
5 changed files with 13 additions and 22 deletions

View File

@@ -650,9 +650,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
[MXSDKOptions.sharedInstance.profiler resume];
_isAppForeground = YES;
// bwi: check if requests need to be blocked
[self checkBlockingServerMaintenance];
}
- (void)applicationDidBecomeActive:(UIApplication *)application
@@ -666,9 +663,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
self.isApplicationActiveFromSystemAlert = NO;
[self checkCrossSigningForSession:self.mxSessions.firstObject];
// bwi: check if requests need to be blocked
[self checkBlockingServerMaintenance];
}
- (void)configurePinCodeScreenFor:(UIApplication *)application
@@ -4591,19 +4585,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
[service registerForAppConfig];
}
#pragma mark - bwi blocking maintenance
// bwi: on appstart and app coming back from background check the current maintenance and block requests if necessary
- (void) checkBlockingServerMaintenance {
ServerDowntimeDefaultService* service = [[ServerDowntimeDefaultService alloc] init];
if( [service isDowntimeNow] && [service isBlocking] && ![service isManuallyIgnored] ) {
[NSUserDefaults.standardUserDefaults setBool:YES forKey:@"ServerDownTimeBlockingKey"];
} else {
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"ServerDownTimeBlockingKey"];
}
}
#pragma mark - Mandatory SSSS setup
- (void)presentSecureBackupSetupForSession:(MXSession*)mxSession

View File

@@ -100,6 +100,8 @@ final class OnboardingCoordinator: NSObject, OnboardingCoordinatorProtocol {
// MARK: - Public
func start() {
// bwi: (#4976) when we start onboarding we want to be sure that we don't block requests
UserDefaults.standard.set(false, forKey: "ServerDownTimeBlockingKey")
// bwi: (#4394) handling of the case of canceled login during pincode stage. Startign the authentication first is needed for startup to work
if !MXKAccountManager.shared().accounts.isEmpty && !PinCodePreferences.shared.isPinSet && PinCodePreferences.shared.forcePinProtection {
if let session = AppDelegate.theDelegate().mxSessions.first as? MXSession {

View File

@@ -5355,6 +5355,8 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
- (void) ignoreDowntime:(id)sender {
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"ServerDownTimeBlockingKey"];
[[[ServerDowntimeDefaultService alloc] init] setManuallyIgnored];
[self updateSections];
}
#pragma mark - ThreadsBetaCoordinatorBridgePresenterDelegate

View File

@@ -339,7 +339,7 @@ struct AuthenticationServerSelectionScreen: View {
self.showAlertIfNeeded()
}
} else {
service.fetchDowntimesWithDirectRequest { success in
service.fetchDowntimesWithDirectRequest(localURLString:viewModel.homeserverAddress) { success in
DispatchQueue.main.async {
self.isFetchingDowntime = false // hide progressview
if success {

View File

@@ -163,8 +163,14 @@ extension ServerDowntimeDefaultService : ServerDowntimeService {
})
}
func fetchDowntimesWithDirectRequest(completion: @escaping (Bool) -> Void) {
guard let url = URL(string: AppConfigService.shared.serverUrl() + maintenanceURL) else {
func fetchDowntimesWithDirectRequest(localUrlString: String? = nil, completion: @escaping (Bool) -> Void) {
var urlString = AppConfigService.shared.serverUrl()
if let localUrlString = localUrlString {
urlString = localUrlString
}
guard let url = URL(string: urlString + maintenanceURL) else {
completion(false)
return
}