diff --git a/Riot/Assets/new_features.html b/Riot/Assets/new_features.html index 91e227f30..e9332f9ff 100644 --- a/Riot/Assets/new_features.html +++ b/Riot/Assets/new_features.html @@ -26,6 +26,18 @@ +
+

+ Version 2.10.1 +

+ +

+ Behobene Bugs +

+

+

Version 2.10.0 diff --git a/Riot/Modules/Application/AppDelegate.swift b/Riot/Modules/Application/AppDelegate.swift index ae85a22ab..91d0b846d 100644 --- a/Riot/Modules/Application/AppDelegate.swift +++ b/Riot/Modules/Application/AppDelegate.swift @@ -78,6 +78,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate { UISwitch.appearance().thumbTintColor = ThemeService.shared().theme.backgroundColor UISwitch.appearance().onTintColor = ThemeService.shared().theme.tintColor +// bwi: testing mdm config +// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { +// let dict = ["home_server_url": ""] +// UserDefaults.standard.setValue(dict, forKey: "com.apple.configuration.managed") +// } + return true } diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index fa6469272..74e09c072 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -4576,10 +4576,15 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni - (void) setupAppConfig { AppConfigService* service = [AppConfigService shared]; - service.completion = ^(BOOL success) { + // bwi: logout when mdm config has changed but only when logged in and config server url is not the same then before + service.completion = ^(BOOL success, NSString* serverUrl) { if( success) { - [self logoutWithoutConfirmation:YES completion:nil]; - NSLog(@"New AppConfig"); + if ([[[MXKAccountManager sharedManager] accounts] count] > 0) { + NSString *currentUrl = [[[self.mxSessions firstObject] matrixRestClient] homeserver]; + if (currentUrl != nil && ![serverUrl isEqualToString:currentUrl]) { + [self logoutWithoutConfirmation:YES completion:nil]; + } + } } }; [service registerForAppConfig]; diff --git a/bwi/AppConfig/AppConfigService.swift b/bwi/AppConfig/AppConfigService.swift index c3357464d..073dee4d0 100644 --- a/bwi/AppConfig/AppConfigService.swift +++ b/bwi/AppConfig/AppConfigService.swift @@ -44,13 +44,15 @@ extension UserDefaults var appConfig = AppConfig() - var completion: ((Bool) -> Void)? + var completion: ((Bool, String) -> Void)? var configObserver: NSKeyValueObservation! var session: MXSession? var isAppConfig: Bool + + var lastDictionary: [String: Any]? private func loadAppConfig() { isAppConfig = false @@ -90,8 +92,24 @@ extension UserDefaults self.loadAppConfig() } - func registerForAppConfig() { + deinit { + NotificationCenter.default.removeObserver(self) + } + + private func isSameConfig( dict: [String: Any]) -> Bool { + if let lastDictionary = lastDictionary { + if lastDictionary.count != dict.count { + return false + } + if let newURl = dict[serverUrlKey] as? String, let oldURL = lastDictionary[serverUrlKey] as? String, newURl == oldURL { + return true + } + } + return false + } + + func registerForAppConfig() { NotificationCenter.default.addObserver(forName: UserDefaults.didChangeNotification, object: nil, queue: OperationQueue.main) { [self] (note) in handleAppConfig() } @@ -99,43 +117,44 @@ extension UserDefaults func handleAppConfig() { if let dict = UserDefaults.standard.dictionary(forKey: configKey) { - var config = AppConfig() - - if let serverUrl = dict[serverUrlKey] as? String { - if serverUrl.count == 0 { - config.serverUrl = nil - } else if checkUrlSavety(serverUrl) { - config.serverUrl = serverUrl + // only compute if serverURL has not changed (this may need to be changed on Adminportal integration + if !isSameConfig(dict: dict) { + var config = AppConfig() + + if let serverUrl = dict[serverUrlKey] as? String { + if serverUrl.count == 0 { + config.serverUrl = nil + } else if checkUrlSavety(serverUrl) { + config.serverUrl = serverUrl + } + } + if let contentScannerUrl = dict[contentScannerKey] as? String { + if checkUrlSavety(contentScannerUrl) { + config.contentScannerUrl = contentScannerUrl + } + } + if let pusherUrl = dict[pusherUrlKey] as? String { + if checkUrlSavety(pusherUrl) { + config.pusherUrl = pusherUrl + } + } + if let permalinkUrl = dict[permalinkUrlKey] as? String { + if checkUrlSavety(permalinkUrl) { + config.permalinkUrl = permalinkUrl + } + } + + // app config needs at least a valid server url + if let serverUrl = config.serverUrl { + isAppConfig = true + appConfig = config + lastDictionary = dict + self.saveAppConfig() + if let completion = self.completion { + completion(true, serverUrl) + } } } - if let contentScannerUrl = dict[contentScannerKey] as? String { - if checkUrlSavety(contentScannerUrl) { - config.contentScannerUrl = contentScannerUrl - } - } - if let pusherUrl = dict[pusherUrlKey] as? String { - if checkUrlSavety(pusherUrl) { - config.pusherUrl = pusherUrl - } - } - if let permalinkUrl = dict[permalinkUrlKey] as? String { - if checkUrlSavety(permalinkUrl) { - config.permalinkUrl = permalinkUrl - } - } - - // app config needs at least a valid server url - isAppConfig = (config.serverUrl != nil) - - if config != appConfig { - appConfig = config - self.saveAppConfig() - if let completion = completion { - completion(true) - } - } - - UserDefaults.standard.removeObject(forKey: configKey) } } @@ -173,4 +192,6 @@ extension UserDefaults return BWIBuildSettings.shared.clientPermalinkBaseUrl } } + + } diff --git a/bwi/WelcomeExperience/WelcomeExperienceView.swift b/bwi/WelcomeExperience/WelcomeExperienceView.swift index a50e8330f..bdc7b088f 100644 --- a/bwi/WelcomeExperience/WelcomeExperienceView.swift +++ b/bwi/WelcomeExperience/WelcomeExperienceView.swift @@ -103,7 +103,7 @@ fileprivate struct Page: View { if success { self.showAlertIfNeeded() } else { - + buttonCallback() } } }