From 446bf6bdcd6466057245cdf4f63bf4cded4a6722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Benaiteau?= Date: Wed, 15 Jan 2025 16:51:05 +0100 Subject: [PATCH 1/3] fix: read from userdefaults environmentType --- wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift b/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift index 71ab2b884d4..f39986a4f6f 100644 --- a/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift +++ b/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift @@ -24,7 +24,8 @@ private let zmsLog = ZMSLog(tag: "backend-environment") public extension BackendEnvironment { static let backendSwitchNotification = Notification.Name("backendEnvironmentSwitchNotification") static var shared: BackendEnvironment = { - var environmentType: EnvironmentType? + // read from userDefaults first + var environmentType: EnvironmentType? = EnvironmentType(userDefaults: .applicationGroup) if let typeOverride = AutomationHelper.sharedHelper.backendEnvironmentTypeOverride() { environmentType = EnvironmentType(stringValue: typeOverride) } From f77a3386685b23c1e46d4b6299449a8e38fa0621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Benaiteau?= Date: Thu, 16 Jan 2025 13:00:54 +0100 Subject: [PATCH 2/3] code review --- .../WireCommonComponents/BackendEnvironment+Shared.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift b/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift index f39986a4f6f..318147275a3 100644 --- a/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift +++ b/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift @@ -24,10 +24,12 @@ private let zmsLog = ZMSLog(tag: "backend-environment") public extension BackendEnvironment { static let backendSwitchNotification = Notification.Name("backendEnvironmentSwitchNotification") static var shared: BackendEnvironment = { - // read from userDefaults first - var environmentType: EnvironmentType? = EnvironmentType(userDefaults: .applicationGroup) + let environmentType: EnvironmentType if let typeOverride = AutomationHelper.sharedHelper.backendEnvironmentTypeOverride() { environmentType = EnvironmentType(stringValue: typeOverride) + } else { + // read from userDefaults first + environmentType = EnvironmentType(userDefaults: .applicationGroup) } guard let environment = BackendEnvironment(type: environmentType) else { From 982b4ec7579e8de00cfb3cfcf195196a7f109b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Benaiteau?= Date: Thu, 16 Jan 2025 13:06:11 +0100 Subject: [PATCH 3/3] code review --- .../WireCommonComponents/BackendEnvironment+Shared.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift b/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift index 318147275a3..f7ce56daf20 100644 --- a/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift +++ b/wire-ios/WireCommonComponents/BackendEnvironment+Shared.swift @@ -24,12 +24,11 @@ private let zmsLog = ZMSLog(tag: "backend-environment") public extension BackendEnvironment { static let backendSwitchNotification = Notification.Name("backendEnvironmentSwitchNotification") static var shared: BackendEnvironment = { - let environmentType: EnvironmentType - if let typeOverride = AutomationHelper.sharedHelper.backendEnvironmentTypeOverride() { - environmentType = EnvironmentType(stringValue: typeOverride) + let environmentType = if let typeOverride = AutomationHelper.sharedHelper.backendEnvironmentTypeOverride() { + EnvironmentType(stringValue: typeOverride) } else { // read from userDefaults first - environmentType = EnvironmentType(userDefaults: .applicationGroup) + EnvironmentType(userDefaults: .applicationGroup) } guard let environment = BackendEnvironment(type: environmentType) else {