Remove the dynamic member lookup from UserSettings in favour of nested access. (#6294)

* Remove the dynamic member lookup from UserSettings in favour of nested access.

* Remove forwarding methods from UserSettings.

* Update the Enterprise submodule.
This commit is contained in:
Doug
2026-10-08 15:19:44 +01:00
committed by GitHub
parent fba28ed422
commit fc75f90ef5
75 changed files with 346 additions and 374 deletions
@@ -31,7 +31,7 @@ class OAuthAccountSettingsPresenter: NSObject {
appHooks: AppHooks,
continuation: Continuation? = nil) {
self.accountURL = accountURL
redirectURL = userSettings.oAuthRedirectURL
redirectURL = userSettings.app.oAuthRedirectURL
self.presentationAnchor = presentationAnchor
self.appMediator = appMediator
self.appHooks = appHooks
@@ -17,13 +17,13 @@ class AnalyticsSettingsScreenViewModel: AnalyticsSettingsScreenViewModelType, An
init(userSettings: UserSettings, analytics: AnalyticsServiceProtocol) {
self.analytics = analytics
let strings = AnalyticsSettingsScreenStrings(termsURL: userSettings.analyticsTermsURL)
let strings = AnalyticsSettingsScreenStrings(termsURL: userSettings.app.analyticsTermsURL)
let bindings = AnalyticsSettingsScreenViewStateBindings(enableAnalytics: analytics.isEnabled)
let state = AnalyticsSettingsScreenViewState(strings: strings, bindings: bindings)
super.init(initialViewState: state)
userSettings.analyticsConsentStatePublisher
userSettings.app.analyticsConsentStatePublisher
.map { $0 == .optedIn }
.weakAssign(to: \.state.bindings.enableAnalytics, on: self)
.store(in: &cancellables)
@@ -13,8 +13,8 @@ typealias LegalInformationScreenViewModelType = StateStoreViewModelV2<LegalInfor
class LegalInformationScreenViewModel: LegalInformationScreenViewModelType, LegalInformationScreenViewModelProtocol {
init(userSettings: UserSettings) {
super.init(initialViewState: LegalInformationScreenViewState(copyrightURL: userSettings.copyrightURL,
acceptableUseURL: userSettings.acceptableUseURL,
privacyURL: userSettings.privacyURL))
super.init(initialViewState: LegalInformationScreenViewState(copyrightURL: userSettings.app.copyrightURL,
acceptableUseURL: userSettings.app.acceptableUseURL,
privacyURL: userSettings.app.privacyURL))
}
}
@@ -33,8 +33,8 @@ struct LocationSharingSettingsScreenViewStateBindings {
}
var liveLocationMinimumDistanceUpdate: Int {
get { userSettings.liveLocationMinimumDistanceUpdate }
set { userSettings.liveLocationMinimumDistanceUpdate = newValue }
get { userSettings.app.liveLocationMinimumDistanceUpdate }
set { userSettings.app.liveLocationMinimumDistanceUpdate = newValue }
}
}
@@ -20,8 +20,8 @@ struct MediaUploadQualitySettingsScreenViewStateBindings {
}
var optimizeMediaUploads: Bool {
get { userSettings.optimizeMediaUploads }
set { userSettings.optimizeMediaUploads = newValue }
get { userSettings.app.optimizeMediaUploads }
set { userSettings.app.optimizeMediaUploads = newValue }
}
}
@@ -32,8 +32,8 @@ struct ModerationAndSafetySettingsScreenViewStateBindings {
}
var sharePresence: Bool {
get { userSettings.sharePresence }
set { userSettings.sharePresence = newValue }
get { userSettings.app.sharePresence }
set { userSettings.app.sharePresence = newValue }
}
}
@@ -38,21 +38,21 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
notificationTonePreviewer = AudioPlayer()
self.notificationToneManager = notificationToneManager
let bindings = NotificationSettingsScreenViewStateBindings(enableNotifications: userSettings.enableNotifications,
showAllRoomListActivity: userSettings.showAllRoomListActivity)
let bindings = NotificationSettingsScreenViewStateBindings(enableNotifications: userSettings.app.enableNotifications,
showAllRoomListActivity: userSettings.app.showAllRoomListActivity)
super.init(initialViewState: NotificationSettingsScreenViewState(bindings: bindings,
isModallyPresented: isModallyPresented,
selectedAlertTone: userSettings.selectedNotificationTone ?? NotificationToneManager.defaultElementXMessageTone,
selectedAlertTone: userSettings.app.selectedNotificationTone ?? NotificationToneManager.defaultElementXMessageTone,
availableCustomTones: notificationToneManager.customTones(),
// macos lacks default sounds and its sandbox Sounds directory is immutable
customToneSelectionEnabled: !ProcessInfo.processInfo.isiOSAppOnMac))
// Listen for changes to UserSettings.
userSettings.enableNotificationsPublisher
userSettings.app.enableNotificationsPublisher
.weakAssign(to: \.state.bindings.enableNotifications, on: self)
.store(in: &cancellables)
userSettings.selectedNotificationTonePublisher
userSettings.app.selectedNotificationTonePublisher
.map { $0 ?? NotificationToneManager.defaultElementXMessageTone }
.weakAssign(to: \.state.selectedAlertTone, on: self)
.store(in: &cancellables)
@@ -104,7 +104,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
}
Task { await enableInvitations(state.bindings.invitationsEnabled) }
case .showAllRoomListActivityChanged:
userSettings.showAllRoomListActivity = state.bindings.showAllRoomListActivity
userSettings.app.showAllRoomListActivity = state.bindings.showAllRoomListActivity
case .close:
actionsSubject.send(.close)
case .fixConfigurationMismatchTapped:
@@ -127,7 +127,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
}
func toggleNotifications() {
userSettings.enableNotifications.toggle()
userSettings.app.enableNotifications.toggle()
}
private func setupDidBecomeActiveSubscription() {
@@ -302,7 +302,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
try notificationToneManager.deleteCustomTone(tone)
if tone == state.selectedAlertTone {
userSettings.selectedNotificationTone = nil
userSettings.app.selectedNotificationTone = nil
}
} catch {
MXLog.error("Error deleting alert tone \(tone.label): \(error)")
@@ -89,8 +89,8 @@ struct SettingsScreenViewStateBindings {
var isPresentingAccountDeactivationConfirmation = false
var appAppearance: AppAppearance {
get { userSettings.appAppearance }
set { userSettings.appAppearance = newValue }
get { userSettings.app.appAppearance }
set { userSettings.app.appAppearance = newValue }
}
init(userSettings: UserSettings) {
@@ -29,25 +29,25 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
userProfile: userSession.clientProxy.userProfilePublisher.value,
showLinkNewDeviceButton: userSettings.linkNewDeviceEnabled,
showAddAccountButton: userSettings.multiAccountEnabled,
showLinkNewDeviceButton: userSettings.app.linkNewDeviceEnabled,
showAddAccountButton: userSettings.app.multiAccountEnabled,
showAccountDeactivation: userSession.clientProxy.canDeactivateAccount,
showDeveloperOptions: userSettings.developerOptionsEnabled,
showAnalyticsSettings: userSettings.canPromptForAnalytics,
showDeveloperOptions: userSettings.app.developerOptionsEnabled,
showAnalyticsSettings: userSettings.app.canPromptForAnalytics,
isBugReportServiceEnabled: isBugReportServiceEnabled,
navigationBarVisibility: isInSecondaryWindow ? .hidden : .automatic,
bindings: .init(userSettings: userSettings)),
mediaProvider: userSession.mediaProvider)
userSettings.developerOptionsEnabledPublisher
userSettings.app.developerOptionsEnabledPublisher
.weakAssign(to: \.state.showDeveloperOptions, on: self)
.store(in: &cancellables)
userSettings.linkNewDeviceEnabledPublisher
userSettings.app.linkNewDeviceEnabledPublisher
.weakAssign(to: \.state.showLinkNewDeviceButton, on: self)
.store(in: &cancellables)
userSettings.multiAccountEnabledPublisher
userSettings.app.multiAccountEnabledPublisher
.weakAssign(to: \.state.showAddAccountButton, on: self)
.store(in: &cancellables)
@@ -144,7 +144,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
actionsSubject.send(.about)
case .enableDeveloperOptions:
userSettings.developerOptionsEnabled.toggle()
userSettings.app.developerOptionsEnabled.toggle()
case .developerOptions:
actionsSubject.send(.developerOptions)
}
@@ -318,8 +318,8 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
displayName: "Alice Liddell",
status: .mockFocussing))))
let userSettings = UserSettings.mock()
userSettings.multiAccountEnabled = true
userSettings.linkNewDeviceEnabled = true
userSettings.app.multiAccountEnabled = true
userSettings.app.linkNewDeviceEnabled = true
return SettingsScreenViewModel(userSession: userSession,
userSettings: userSettings,
isBugReportServiceEnabled: isBugReportServiceEnabled,