diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index f50931d1b..e1fd32584 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -36,7 +36,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { /// If we are running automated tests we should process environment variables before we do anything else - DeveloperSettingsViewModel.processUnitTestEnvVariablesIfNeeded() + DeveloperSettingsViewModel.processUnitTestEnvVariablesIfNeeded(using: dependencies) #if DEBUG /// If we are running a Preview then we don't want to setup the application (previews are generally self contained individual views so diff --git a/Session/Settings/DeveloperSettingsViewModel.swift b/Session/Settings/DeveloperSettingsViewModel.swift index e91b10049..9bbd10acd 100644 --- a/Session/Settings/DeveloperSettingsViewModel.swift +++ b/Session/Settings/DeveloperSettingsViewModel.swift @@ -779,6 +779,14 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, } private func updateServiceNetwork(to updatedNetwork: ServiceNetwork?) { + DeveloperSettingsViewModel.updateServiceNetwork(to: updatedNetwork, using: dependencies) + forceRefresh(type: .databaseQuery) + } + + private static func updateServiceNetwork( + to updatedNetwork: ServiceNetwork?, + using dependencies: Dependencies + ) { struct IdentityData { let ed25519KeyPair: KeyPair let x25519KeyPair: KeyPair @@ -888,8 +896,6 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, Log.info("[DevSettings] Completed swap to \(String(describing: updatedNetwork))") } - - forceRefresh(type: .databaseQuery) } private func updateFlag(for feature: FeatureConfig, to updatedFlag: Bool?) { @@ -1303,10 +1309,14 @@ class DeveloperSettingsViewModel: SessionTableViewModel, NavigatableStateHolder, // MARK: - Automated Test Convenience extension DeveloperSettingsViewModel { - static func processUnitTestEnvVariablesIfNeeded() { + static func processUnitTestEnvVariablesIfNeeded(using dependencies: Dependencies) { #if targetEnvironment(simulator) enum EnvironmentVariable: String { case animationsEnabled + case showStringKeys + + case serviceNetwork + case forceOffline } ProcessInfo.processInfo.environment.forEach { key, value in @@ -1314,9 +1324,27 @@ extension DeveloperSettingsViewModel { switch variable { case .animationsEnabled: + dependencies.set(feature: .animationsEnabled, to: (value == "true")) + guard value == "false" else { return } UIView.setAnimationsEnabled(false) + + case .showStringKeys: + dependencies.set(feature: .showStringKeys, to: (value == "true")) + + case .serviceNetwork: + let network: ServiceNetwork + + switch value { + case "testnet": network = .testnet + default: network = .mainnet + } + + DeveloperSettingsViewModel.updateServiceNetwork(to: network, using: dependencies) + + case .forceOffline: + dependencies.set(feature: .forceOffline, to: (value == "true")) } } #endif