Added additional settings controllable via env vars

pull/894/head
Morgan Pretty 4 months ago
parent 1dbfc31a2a
commit c25d9efc4a

@ -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

@ -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<Bool>, 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

Loading…
Cancel
Save