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
@@ -495,8 +495,8 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
if oldVersion < Version(1, 6, 0) {
MXLog.info("Migrating to v1.6.0, marking identity confirmation onboarding as ran.")
userSession.userSettings.hasRunIdentityConfirmationOnboarding = true
userSession.userSettings.hasRunNotificationPermissionsOnboarding = true
userSession.userSettings.account.hasRunIdentityConfirmationOnboarding = true
userSession.userSettings.app.hasRunNotificationPermissionsOnboarding = true
}
if oldVersion < Version(25, 6, 0) {
@@ -521,8 +521,8 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
if oldVersion < Version(26, 10, 1) {
MXLog.info("Migrating to version 26.10.1, moving initial 'session specific' settings.")
userSession.userSettings.migrateAppSettingsValueToAccountSettings(\.hasRunIdentityConfirmationOnboardingKey)
userSession.userSettings.migrateAppSettingsValueToAccountSettings(\.searchBreadcrumbsKey)
userSession.userSettings.account.migrateAppSettingsValue(\.hasRunIdentityConfirmationOnboardingKey)
userSession.userSettings.account.migrateAppSettingsValue(\.searchBreadcrumbsKey)
}
userSessionMigrationsOldVersion = nil
@@ -872,7 +872,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
userSessionStore.logout(userSession: userSession)
tearDownUserSession()
userSession.userSettings.resetSessionSpecificSettings()
userSession.userSettings.account.reset()
appHooks.remoteSettingsHook.reset(appSettings)
// Reset analytics
@@ -1385,7 +1385,7 @@ private extension AppCoordinator {
}
func scheduleSearchBackfill() {
guard let userSession, userSession.userSettings.globalSearchEnabled, #available(iOS 26.0, *) else {
guard let userSession, userSession.userSettings.app.globalSearchEnabled, #available(iOS 26.0, *) else {
return
}
@@ -10,44 +10,16 @@ import Macros
/// The settings for a signed in account, composed of the app wide settings and the settings
/// specific to that account.
@dynamicMemberLookup
final nonisolated class UserSettings: Sendable {
// TODO: @pixlwave Make this private after handling Advanced/Labs/Developer screen models.
let app: AppSettings
private let account: AccountSettings
let account: AccountSettings
init(appSettings: AppSettings, accountSettings: AccountSettings) {
self.app = appSettings
self.account = accountSettings
app = appSettings
account = accountSettings
}
static func mock(userID: String = "@me:matrix.org") -> UserSettings {
AppSettings.volatile().userSettings(for: userID)
}
subscript<Value>(dynamicMember keyPath: ReferenceWritableKeyPath<AppSettings, Value>) -> Value {
get { app[keyPath: keyPath] }
set { app[keyPath: keyPath] = newValue }
}
subscript<Value>(dynamicMember keyPath: KeyPath<AppSettings, Value>) -> Value {
app[keyPath: keyPath]
}
subscript<Value>(dynamicMember keyPath: ReferenceWritableKeyPath<AccountSettings, Value>) -> Value {
get { account[keyPath: keyPath] }
set { account[keyPath: keyPath] = newValue }
}
subscript<Value>(dynamicMember keyPath: KeyPath<AccountSettings, Value>) -> Value {
account[keyPath: keyPath]
}
func migrateAppSettingsValueToAccountSettings(_ keyPath: KeyPath<AccountSettings, UserPreferenceKey>) {
account.migrateAppSettingsValue(keyPath)
}
func resetSessionSpecificSettings() {
account.reset()
}
}