From fccad5fc305d087d6789cd6195de135cab0d6521 Mon Sep 17 00:00:00 2001 From: Doug Date: Fri, 25 Sep 2026 13:51:33 +0100 Subject: [PATCH] Replace AppSettings with UserSettings from the UserSessionFlow and below. Remove some redundant injections when passed alongside a user session too. # Conflicts: # ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift # ElementX/Sources/Screens/Timeline/TimelineViewModel.swift --- ElementX.xcodeproj/project.pbxproj | 8 ++ .../Sources/Application/AppCoordinator.swift | 6 +- .../Application/FlowCoordinatorProtocol.swift | 2 +- .../ChatsTabFlowCoordinator.swift | 3 +- .../EncryptionResetFlowCoordinator.swift | 7 +- .../EncryptionSettingsFlowCoordinator.swift | 7 +- .../MediaEventsTimelineFlowCoordinator.swift | 2 +- .../OnboardingFlowCoordinator.swift | 25 +++--- .../PinnedEventsTimelineFlowCoordinator.swift | 6 +- .../RoomFlowCoordinator.swift | 27 ++++--- .../SettingsFlowCoordinator.swift | 21 +++-- .../SpaceFlowCoordinator.swift | 2 +- .../SpaceSettingsFlowCoordinator.swift | 6 +- .../StartChatFlowCoordinator.swift | 2 +- .../UserSessionFlowCoordinator.swift | 18 ++--- .../Sources/Mocks/ClientFactoryMock.swift | 2 +- .../Mocks/Generated/GeneratedMocks.swift | 69 +++++++++-------- ElementX/Sources/Mocks/UserSessionMock.swift | 3 + .../Other/SwiftUI/Views/VisualListItem.swift | 2 +- .../CallScreen/CallScreenCoordinator.swift | 4 +- .../CallScreen/CallScreenViewModel.swift | 14 ++-- .../Screens/CallScreen/View/CallScreen.swift | 2 +- .../CreateRoomScreenCoordinator.swift | 4 +- .../CreateRoomScreenViewModel.swift | 6 +- .../View/CreateRoomScreen.swift | 6 +- .../View/CreateRoomSpaceSelectionSheet.swift | 4 +- .../View/EmojiPickerScreen.swift | 4 +- .../HomeScreen/HomeScreenCoordinator.swift | 4 +- .../HomeScreen/HomeScreenViewModel.swift | 28 +++---- .../View/Filters/RoomListFilterModels.swift | 10 +-- .../RoomListFiltersEmptyStateView.swift | 4 +- .../View/Filters/RoomListFiltersView.swift | 6 +- .../Screens/HomeScreen/View/HomeScreen.swift | 2 +- .../View/HomeScreenEmptyStateView.swift | 2 +- .../View/HomeScreenInviteCell.swift | 2 +- .../View/HomeScreenKnockedCell.swift | 2 +- ...eScreenRecoveryKeyConfirmationBanner.swift | 2 +- .../JoinRoomScreenCoordinator.swift | 4 +- .../JoinRoomScreenViewModel.swift | 12 +-- .../JoinRoomScreen/View/JoinRoomScreen.swift | 4 +- .../LabsScreen/LabsScreenCoordinator.swift | 4 +- .../LocationSharingScreenCoordinator.swift | 4 +- .../LocationSharingScreenViewModel.swift | 18 ++--- ...MediaEventsTimelineScreenCoordinator.swift | 4 +- .../View/MediaEventsTimelineScreen.swift | 4 +- .../View/MediaUploadPreviewScreen.swift | 2 +- .../View/AnalyticsPromptScreen.swift | 2 +- ...dentityConfirmationScreenCoordinator.swift | 4 +- .../IdentityConfirmationScreenViewModel.swift | 4 +- .../View/IdentityConfirmationScreen.swift | 2 +- ...SessionVerificationScreenCoordinator.swift | 4 +- .../SessionVerificationScreenViewModel.swift | 4 +- .../View/SessionVerificationScreen.swift | 2 +- ...innedEventsTimelineScreenCoordinator.swift | 5 +- .../PinnedEventsTimelineScreenViewModel.swift | 8 +- .../View/PinnedEventsTimelineScreen.swift | 2 +- .../QRCodeLoginScreenModels.swift | 2 +- .../View/RoomDetailsEditScreen.swift | 2 +- .../RoomDetailsScreenCoordinator.swift | 4 +- .../RoomDetailsScreenViewModel.swift | 4 +- .../View/RoomDetailsScreen.swift | 6 +- .../ComposerToolbarViewModel.swift | 6 +- .../View/RoomAttachmentPicker.swift | 4 +- .../RoomScreen/RoomScreenCoordinator.swift | 15 ++-- .../RoomScreen/RoomScreenViewModel.swift | 20 +++-- .../Screens/RoomScreen/View/RoomScreen.swift | 10 +-- .../SearchScreenCoordinator.swift | 4 +- .../SearchScreen/SearchScreenViewModel.swift | 14 ++-- .../SearchScreen/View/SearchScreen.swift | 28 +++---- .../SecureBackupScreenCoordinator.swift | 4 +- .../SecurityAndPrivacyScreenCoordinator.swift | 4 +- .../SecurityAndPrivacyScreenViewModel.swift | 14 ++-- .../View/SecurityAndPrivacyScreen.swift | 34 ++++---- .../OAuthAccountSettingsPresenter.swift | 4 +- .../AdvancedSettingsScreenCoordinator.swift | 4 +- .../AdvancedSettingsScreenViewModel.swift | 2 +- .../View/AdvancedSettingsScreen.swift | 11 +-- .../AnalyticsSettingsScreenCoordinator.swift | 4 +- .../AnalyticsSettingsScreenViewModel.swift | 6 +- .../View/AnalyticsSettingsScreen.swift | 4 +- .../LegalInformationScreenCoordinator.swift | 4 +- .../LegalInformationScreenViewModel.swift | 8 +- .../View/LegalInformationScreen.swift | 2 +- ...otificationSettingsScreenCoordinator.swift | 6 +- .../NotificationSettingsScreenViewModel.swift | 24 +++--- .../View/NotificationSettingsScreen.swift | 8 +- .../SettingsScreenCoordinator.swift | 4 +- .../SettingsScreenViewModel.swift | 18 ++--- .../SettingsScreen/View/SettingsScreen.swift | 2 +- .../View/UserDetailsEditScreen.swift | 2 +- .../View/SpaceSettingsScreen.swift | 2 +- .../View/StartChatScreen.swift | 2 +- .../ThreadTimelineScreenCoordinator.swift | 15 ++-- .../Timeline/TimelineInteractionHandler.swift | 14 ++-- .../Screens/Timeline/TimelineViewModel.swift | 45 +++++------ .../View/ItemMenu/TimelineItemMenu.swift | 2 +- .../ReadReceiptsSummaryView.swift | 5 +- .../Style/TimelineItemBubbledStylerView.swift | 30 ++++---- .../TimelineReadReceiptsView.swift | 25 +++--- .../HighlightedTimelineItemModifier.swift | 27 +++---- .../Screens/Timeline/View/TimelineView.swift | 25 +++--- .../AlertTones/NotificationToneManager.swift | 10 +-- .../Services/Client/ClientFactory.swift | 6 +- .../Client/ClientFactoryProtocol.swift | 2 +- .../Sources/Services/Client/ClientProxy.swift | 28 +++---- .../Services/Emojis/EmojiProvider.swift | 14 ++-- .../Location/LiveLocationManager.swift | 34 ++++---- .../Media/MediaUploadingPreprocessor.swift | 6 +- .../Services/Presence/PresenceService.swift | 10 +-- .../Services/Room/JoinedRoomProxy.swift | 10 +-- .../RoomSummary/RoomSummaryProvider.swift | 12 +-- .../TimelineController.swift | 8 +- .../TimelineControllerFactory.swift | 10 +-- .../UITests/UITestsAppCoordinator.swift | 77 ++++++++----------- NSE/Sources/NSEUserSession.swift | 12 +-- .../NotificationServiceExtension.swift | 2 +- .../ShareExtensionViewController.swift | 10 +-- 117 files changed, 554 insertions(+), 594 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index e42d6643c..ba71bf185 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -431,6 +431,7 @@ 44BDD670FF9095ACE240A3A2 /* VoiceMessageMediaManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC4F10BDD56FA77FEC742333 /* VoiceMessageMediaManagerTests.swift */; }; 44D3EA8583C54BA3D8058499 /* SyncServiceSDKMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33DBBBC78047C669166C9F7C /* SyncServiceSDKMock.swift */; }; 44F0E1B576C7599DF8022071 /* SentrySwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 75361A9D8A3C5501EADB225D /* SentrySwiftUI */; }; + 452507BCE97B3EA0F24E206E /* UserSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 100DA305FE28BB3B6AEDE1FD /* UserSettings.swift */; }; 454311EAC17D778E19F46592 /* NotificationPermissionsScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91868EB98818044E6FEBE532 /* NotificationPermissionsScreenCoordinator.swift */; }; 454F8DDC4442C0DE54094902 /* LABiometryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3F219838588C62198E726E3 /* LABiometryType.swift */; }; 45D6DC594816288983627484 /* UITestsScreenIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CEBE5EA91E8691EDF364EC2 /* UITestsScreenIdentifier.swift */; }; @@ -1122,6 +1123,7 @@ AF2ABA2794E376B64104C964 /* MockSoftLogoutScreenState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5644919DB2022397D9D5825A /* MockSoftLogoutScreenState.swift */; }; AF33B9044498211C3D82F1E1 /* UNTextInputNotificationResponse+Creator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 130ED565A078F7E0B59D9D25 /* UNTextInputNotificationResponse+Creator.swift */; }; AF4510502727E2ABC326C5FD /* test_animated_image.gif in Resources */ = {isa = PBXBuildFile; fileRef = BDB0DD6E869B4764958CD7AB /* test_animated_image.gif */; }; + AF640383EC85741D33F7558F /* UserSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 100DA305FE28BB3B6AEDE1FD /* UserSettings.swift */; }; AF8BFA37791E1756EE243E08 /* SettingsScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B8F0ED874DF8C9A51B0AB6F /* SettingsScreenCoordinator.swift */; }; AFE2AB612A1460E49578D746 /* JoinRoomScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BDCCD2F6B405C14B9BCE94E /* JoinRoomScreenCoordinator.swift */; }; B004A08BE32F06832BF41CFC /* RoomDetailsScreenHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3674212CAB6C5143DD437AC4 /* RoomDetailsScreenHook.swift */; }; @@ -1360,6 +1362,7 @@ D5E8EE8A288EFCCF646860EA /* KnockRequestsBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F441A78A5CAA9E2937E463 /* KnockRequestsBannerView.swift */; }; D5FE90A6AF5FD5AE91BD37C7 /* NotificationSettingsEditScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 780258F1B9D15E30549FF4BE /* NotificationSettingsEditScreenViewModel.swift */; }; D6152E21036B88C44ECB22E7 /* EncryptionResetPasswordScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 303D9438EFB481F57A366E82 /* EncryptionResetPasswordScreenViewModel.swift */; }; + D61FCF6ABC1490F630E76AEC /* UserSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 100DA305FE28BB3B6AEDE1FD /* UserSettings.swift */; }; D63974A88CF2BC721F109C77 /* Compound in Frameworks */ = {isa = PBXBuildFile; productRef = DCA3C4A997AD28E6918D4CE5 /* Compound */; }; D69CCEC785E6C819551B402F /* SearchScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5413213B56FB76C1071E2BFB /* SearchScreenViewModelTests.swift */; }; D6DE764B17FB4A9A12C33BF4 /* MessageComposer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F1DF3FFFE5ED2B8133F43A7 /* MessageComposer.swift */; }; @@ -1853,6 +1856,7 @@ 0F793C422BDACE0C60C774F4 /* UserIdentityProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserIdentityProxyProtocol.swift; sourceTree = ""; }; 0FA60F848D1C14F873F9621A /* RoomMemberDetailsScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMemberDetailsScreenCoordinator.swift; sourceTree = ""; }; 0FD22AEFFA20065494ED2333 /* AppAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAppearance.swift; sourceTree = ""; }; + 100DA305FE28BB3B6AEDE1FD /* UserSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSettings.swift; sourceTree = ""; }; 104B7747499487538483FEAF /* SpacesScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpacesScreen.swift; sourceTree = ""; }; 105429F29096729EDD3152CF /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/SAS.strings; sourceTree = ""; }; 1059E2AE7878CF7820592637 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; @@ -6897,6 +6901,7 @@ 095B8ED0CA87F4A0A4858719 /* SearchBreadcrumb.swift */, 10D751743B20B314D84D79FE /* TrackedUserDefaults.swift */, 0CCA4547BE58E17899E95CDE /* UserDefaultsProtocol.swift */, + 100DA305FE28BB3B6AEDE1FD /* UserSettings.swift */, F2F56C9FFE8D55375CED9741 /* VolatileUserDefaults.swift */, ); path = Settings; @@ -8311,6 +8316,7 @@ D98B5EE8C4F5A2CE84687AE8 /* UTType.swift in Sources */, 34357B287357BC0B9715DD51 /* UserAgentBuilder.swift in Sources */, 1B1404DD4BB2C5079B074210 /* UserDefaultsProtocol.swift in Sources */, + D61FCF6ABC1490F630E76AEC /* UserSettings.swift in Sources */, 28A494A66D0F21EC1EC4EB11 /* VolatileUserDefaults.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -8560,6 +8566,7 @@ 26252AA9AED64010788F4C26 /* UIView.swift in Sources */, 66E9202BED03B5BB00E812A1 /* URL.swift in Sources */, 29E411E37D3FBF3899B3ED69 /* UserDefaultsProtocol.swift in Sources */, + 452507BCE97B3EA0F24E206E /* UserSettings.swift in Sources */, CDD76A7D42E1B47F7E423AA8 /* VolatileUserDefaults.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -9675,6 +9682,7 @@ 7E91BAC17963ED41208F489B /* UserSessionStore.swift in Sources */, 79D57E9AE03A2DC689D14EA2 /* UserSessionStoreMock.swift in Sources */, AC69B6DF15FC451AB2945036 /* UserSessionStoreProtocol.swift in Sources */, + AF640383EC85741D33F7558F /* UserSettings.swift in Sources */, 9707AF8D41667FA9B35E8953 /* UserToInvite.swift in Sources */, 2447FADEF13225BB6227B977 /* VerificationBadge.swift in Sources */, 5C33976A720B64094CBC56B1 /* VideoMediaEventsTimelineView.swift in Sources */, diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index 99231e2be..318ef4da8 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -775,11 +775,11 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg let flowParameters = CommonFlowParameters(userSession: userSession, bugReportService: bugReportService, elementCallService: elementCallService, - timelineControllerFactory: TimelineControllerFactory(appSettings: appSettings), - emojiProvider: EmojiProvider(appSettings: appSettings), + timelineControllerFactory: TimelineControllerFactory(userSettings: userSession.userSettings), + emojiProvider: EmojiProvider(userSettings: userSession.userSettings), linkMetadataProvider: LinkMetadataProvider(), appMediator: appMediator, - appSettings: appSettings, + userSettings: userSession.userSettings, // TODO: @pixlwave Remove this in favour of the userSession. appHooks: appHooks, analytics: analyticsService, userIndicatorController: userIndicatorController, diff --git a/ElementX/Sources/Application/FlowCoordinatorProtocol.swift b/ElementX/Sources/Application/FlowCoordinatorProtocol.swift index 847f149a1..ca0929577 100644 --- a/ElementX/Sources/Application/FlowCoordinatorProtocol.swift +++ b/ElementX/Sources/Application/FlowCoordinatorProtocol.swift @@ -31,7 +31,7 @@ struct CommonFlowParameters { let emojiProvider: EmojiProviderProtocol let linkMetadataProvider: LinkMetadataProviderProtocol let appMediator: AppMediatorProtocol - let appSettings: AppSettings + let userSettings: UserSettings let appHooks: AppHooks let analytics: AnalyticsServiceProtocol let userIndicatorController: UserIndicatorControllerProtocol diff --git a/ElementX/Sources/FlowCoordinators/ChatsTabFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/ChatsTabFlowCoordinator.swift index ce84bd3d7..c8be799ec 100644 --- a/ElementX/Sources/FlowCoordinators/ChatsTabFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/ChatsTabFlowCoordinator.swift @@ -383,7 +383,7 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol { let parameters = HomeScreenCoordinatorParameters(userSession: userSession, bugReportService: flowParameters.bugReportService, selectedRoomPublisher: selectedRoomSubject.asCurrentValuePublisher(), - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, analyticsService: flowParameters.analytics, notificationManager: flowParameters.notificationManager, userIndicatorController: flowParameters.userIndicatorController) @@ -687,7 +687,6 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol { let sheetNavigationStackCoordinator = NavigationStackCoordinator() let parameters = EncryptionResetFlowCoordinatorParameters(userSession: userSession, appMediator: flowParameters.appMediator, - appSettings: flowParameters.appSettings, appHooks: flowParameters.appHooks, userIndicatorController: flowParameters.userIndicatorController, navigationStackCoordinator: sheetNavigationStackCoordinator, diff --git a/ElementX/Sources/FlowCoordinators/EncryptionResetFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/EncryptionResetFlowCoordinator.swift index e260d56a5..409afc80e 100644 --- a/ElementX/Sources/FlowCoordinators/EncryptionResetFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/EncryptionResetFlowCoordinator.swift @@ -20,7 +20,6 @@ enum EncryptionResetFlowCoordinatorAction: Equatable { struct EncryptionResetFlowCoordinatorParameters { let userSession: UserSessionProtocol let appMediator: AppMediatorProtocol - let appSettings: AppSettings let appHooks: AppHooks let userIndicatorController: UserIndicatorControllerProtocol let navigationStackCoordinator: NavigationStackCoordinator @@ -30,7 +29,7 @@ struct EncryptionResetFlowCoordinatorParameters { class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol { private let userSession: UserSessionProtocol private let appMediator: AppMediatorProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let appHooks: AppHooks private let userIndicatorController: UserIndicatorControllerProtocol @@ -67,7 +66,7 @@ class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol { init(parameters: EncryptionResetFlowCoordinatorParameters) { userSession = parameters.userSession appMediator = parameters.appMediator - appSettings = parameters.appSettings + userSettings = parameters.userSession.userSettings appHooks = parameters.appHooks userIndicatorController = parameters.userIndicatorController navigationStackCoordinator = parameters.navigationStackCoordinator @@ -165,7 +164,7 @@ class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol { accountSettingsPresenter = OAuthAccountSettingsPresenter(accountURL: url, presentationAnchor: windowManager.mainWindow, appMediator: appMediator, - appSettings: appSettings, + userSettings: userSettings, appHooks: appHooks) accountSettingsPresenter?.start() } diff --git a/ElementX/Sources/FlowCoordinators/EncryptionSettingsFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/EncryptionSettingsFlowCoordinator.swift index a783442eb..144cef938 100644 --- a/ElementX/Sources/FlowCoordinators/EncryptionSettingsFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/EncryptionSettingsFlowCoordinator.swift @@ -17,7 +17,6 @@ enum EncryptionSettingsFlowCoordinatorAction: Equatable { struct EncryptionSettingsFlowCoordinatorParameters { let userSession: UserSessionProtocol - let appSettings: AppSettings let appHooks: AppHooks let userIndicatorController: UserIndicatorControllerProtocol let navigationStackCoordinator: NavigationStackCoordinator @@ -25,7 +24,7 @@ struct EncryptionSettingsFlowCoordinatorParameters { class EncryptionSettingsFlowCoordinator: FlowCoordinatorProtocol { private let userSession: UserSessionProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let appHooks: AppHooks private let userIndicatorController: UserIndicatorControllerProtocol private let navigationStackCoordinator: NavigationStackCoordinator @@ -66,7 +65,7 @@ class EncryptionSettingsFlowCoordinator: FlowCoordinatorProtocol { init(parameters: EncryptionSettingsFlowCoordinatorParameters) { userSession = parameters.userSession - appSettings = parameters.appSettings + userSettings = parameters.userSession.userSettings appHooks = parameters.appHooks userIndicatorController = parameters.userIndicatorController navigationStackCoordinator = parameters.navigationStackCoordinator @@ -139,7 +138,7 @@ class EncryptionSettingsFlowCoordinator: FlowCoordinatorProtocol { } private func presentSecureBackupScreen(animated: Bool = true) { - let coordinator = SecureBackupScreenCoordinator(parameters: .init(appSettings: appSettings, + let coordinator = SecureBackupScreenCoordinator(parameters: .init(userSettings: userSettings, clientProxy: userSession.clientProxy, userIndicatorController: userIndicatorController)) coordinator.actions.sink { [weak self] action in diff --git a/ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift index 61240a2e9..4ffa0796d 100644 --- a/ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift @@ -84,7 +84,7 @@ class MediaEventsTimelineFlowCoordinator: FlowCoordinatorProtocol { userSession: userSession, mediaPlayerProvider: MediaPlayerProvider(), appMediator: flowParameters.appMediator, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, analytics: flowParameters.analytics, emojiProvider: flowParameters.emojiProvider, linkMetadataProvider: flowParameters.linkMetadataProvider, diff --git a/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift index 03715e74d..61e851c45 100644 --- a/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/OnboardingFlowCoordinator.swift @@ -21,7 +21,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { private let appLockService: AppLockServiceProtocol private let analyticsService: AnalyticsServiceProtocol private let appMediator: AppMediatorProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let appHooks: AppHooks private let notificationManager: NotificationManagerProtocol private let userIndicatorController: UserIndicatorControllerProtocol @@ -69,7 +69,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { self.appLockService = appLockService analyticsService = flowParameters.analytics appMediator = flowParameters.appMediator - appSettings = flowParameters.appSettings + userSettings = flowParameters.userSettings appHooks = flowParameters.appHooks notificationManager = flowParameters.notificationManager userIndicatorController = flowParameters.userIndicatorController @@ -94,7 +94,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { value == .verified, stateMachine.state == .identityConfirmation else { return } - appSettings.hasRunIdentityConfirmationOnboarding = true + userSettings.hasRunIdentityConfirmationOnboarding = true stateMachine.tryEvent(.nextSkippingIdentityConfirmed) } } @@ -129,11 +129,11 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { private var requiresVerification: Bool { // We want to make sure onboarding finishes but also every time the user becomes unverified (e.g. account reset) - !appSettings.hasRunIdentityConfirmationOnboarding || userSession.sessionSecurityStatePublisher.value.verificationState == .unverified + !userSettings.hasRunIdentityConfirmationOnboarding || userSession.sessionSecurityStatePublisher.value.verificationState == .unverified } private var requiresAppLockSetup: Bool { - appSettings.appLockIsMandatory && !appLockService.isEnabled + userSettings.appLockIsMandatory && !appLockService.isEnabled } private var requiresAnalyticsSetup: Bool { @@ -141,7 +141,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { } private var requiresNotificationsSetup: Bool { - !appSettings.hasRunNotificationPermissionsOnboarding + !userSettings.hasRunNotificationPermissionsOnboarding } private func configureStateMachine() { @@ -225,7 +225,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { presentNotificationPermissionsScreen() case (_, _, .finished): isNewLogin = false - appSettings.hasSignedInBefore = true + userSettings.hasSignedInBefore = true actionsSubject.send(.dismiss) stateMachine.tryState(.initial) case (.finished, _, .initial): @@ -248,7 +248,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { private func presentIdentityConfirmationScreen() { let parameters = IdentityConfirmationScreenCoordinatorParameters(userSession: userSession, - appSettings: appSettings, + userSettings: userSettings, userIndicatorController: userIndicatorController) let coordinator = IdentityConfirmationScreenCoordinator(parameters: parameters) @@ -261,7 +261,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { case .recoveryKey: presentRecoveryKeyScreen() case .skip: - appSettings.hasRunIdentityConfirmationOnboarding = true + userSettings.hasRunIdentityConfirmationOnboarding = true stateMachine.tryEvent(.nextSkippingIdentityConfirmed) case .reset: startEncryptionResetFlow() @@ -281,7 +281,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController, flow: .deviceInitiator, - appSettings: appSettings, + userSettings: userSettings, mediaProvider: userSession.mediaProvider) let coordinator = SessionVerificationScreenCoordinator(parameters: parameters) @@ -322,7 +322,6 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { let resetNavigationStackCoordinator = NavigationStackCoordinator() let coordinator = EncryptionResetFlowCoordinator(parameters: .init(userSession: userSession, appMediator: appMediator, - appSettings: appSettings, appHooks: appHooks, userIndicatorController: userIndicatorController, navigationStackCoordinator: resetNavigationStackCoordinator, @@ -385,7 +384,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { } private func presentAnalyticsPromptScreen() { - let coordinator = AnalyticsPromptScreenCoordinator(analytics: analyticsService, termsURL: appSettings.analyticsTermsURL) + let coordinator = AnalyticsPromptScreenCoordinator(analytics: analyticsService, termsURL: userSettings.analyticsTermsURL) coordinator.actions .sink { [weak self] action in @@ -408,7 +407,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol { guard let self else { return } switch action { case .done: - appSettings.hasRunNotificationPermissionsOnboarding = true + userSettings.hasRunNotificationPermissionsOnboarding = true stateMachine.tryEvent(.next) } } diff --git a/ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift index 9ae6e46a8..d7fa1cf91 100644 --- a/ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift @@ -69,7 +69,7 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol { userSession: userSession, mediaPlayerProvider: MediaPlayerProvider(), appMediator: flowParameters.appMediator, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, analytics: flowParameters.analytics, emojiProvider: flowParameters.emojiProvider, linkMetadataProvider: flowParameters.linkMetadataProvider, @@ -107,11 +107,11 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol { let stackCoordinator = NavigationStackCoordinator() let params = LocationSharingScreenCoordinatorParameters(interactionMode: interactionMode, - mapURLBuilder: flowParameters.appSettings.mapTilerConfiguration.publisher.value, + mapURLBuilder: flowParameters.userSettings.mapTilerConfiguration.publisher.value, roomProxy: roomProxy, timelineController: timelineController, liveLocationManager: flowParameters.userSession.liveLocationManager, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, appMediator: flowParameters.appMediator, analytics: flowParameters.analytics, userIndicatorController: flowParameters.userIndicatorController, diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift index 2e5411158..0ec42f31d 100644 --- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift @@ -238,7 +238,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { defer { hideLoadingIndicator() } switch await roomProxy.loadOrFetchEventDetails(for: eventID) { case .success(let event): - if flowParameters.appSettings.threadsEnabled, let threadRootEventID = event.threadRootEventId() { + if flowParameters.userSettings.threadsEnabled, let threadRootEventID = event.threadRootEventId() { if case .thread(threadRootEventID: threadRootEventID, _) = stateMachine.state, let threadCoordinator = childThreadScreenCoordinators.last { threadCoordinator.focusOnEvent(eventID: eventID) } else { @@ -318,7 +318,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { // Otherwise check if the focussed event exists to handle a possible error or theaded event. switch await roomProxy.loadOrFetchEventDetails(for: focusEvent.eventID) { case .success(let event): - if flowParameters.appSettings.threadsEnabled, let threadRootEventID = event.threadRootEventId() { + if flowParameters.userSettings.threadsEnabled, let threadRootEventID = event.threadRootEventId() { stateMachine.tryEvent(.presentRoom(presentationAction: .thread(rootEventID: threadRootEventID, focusEvent: .init(eventID: focusEvent.eventID, shouldSetPin: focusEvent.shouldSetPin))), @@ -681,7 +681,6 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { completionSuggestionService: completionSuggestionService, ongoingCallRoomIDPublisher: flowParameters.ongoingCallRoomIDPublisher, appMediator: flowParameters.appMediator, - appSettings: flowParameters.appSettings, appHooks: flowParameters.appHooks, analytics: flowParameters.analytics, composerDraftService: composerDraftService, @@ -799,7 +798,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { linkMetadataProvider: flowParameters.linkMetadataProvider, completionSuggestionService: completionSuggestionService, appMediator: flowParameters.appMediator, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, analytics: flowParameters.analytics, composerDraftService: composerDraftService, timelineControllerFactory: flowParameters.timelineControllerFactory, @@ -857,7 +856,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { let coordinator = JoinRoomScreenCoordinator(parameters: .init(source: .generic(roomID: roomID, via: via), userSession: userSession, userIndicatorController: flowParameters.userIndicatorController, - appSettings: flowParameters.appSettings)) + userSettings: flowParameters.userSettings)) joinRoomScreenCoordinator = coordinator @@ -940,7 +939,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { private func presentRoomDetails(isRoot: Bool, animated: Bool) async { let params = RoomDetailsScreenCoordinatorParameters(roomProxy: roomProxy, userSession: userSession, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, appHooks: flowParameters.appHooks, analyticsService: flowParameters.analytics, userIndicatorController: flowParameters.userIndicatorController, @@ -1020,7 +1019,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { let roomDetailsEditParameters = RoomDetailsEditScreenCoordinatorParameters(roomProxy: roomProxy, userSession: userSession, - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: flowParameters.appSettings), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSettings), navigationStackCoordinator: stackCoordinator, userIndicatorController: flowParameters.userIndicatorController, orientationManager: flowParameters.appMediator.windowManager) @@ -1120,9 +1119,9 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { let parameters = MediaUploadPreviewScreenCoordinatorParameters(mediaURLs: mediaURLs, caption: caption, title: title, - shouldShowCaptionWarning: flowParameters.appSettings.shouldShowMediaCaptionWarning, - galleryEnabled: flowParameters.appSettings.galleryEnabled, - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: flowParameters.appSettings), + shouldShowCaptionWarning: flowParameters.userSettings.shouldShowMediaCaptionWarning, + galleryEnabled: flowParameters.userSettings.galleryEnabled, + mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSettings), timelineController: timelineController, clientProxy: userSession.clientProxy, userIndicatorController: flowParameters.userIndicatorController) @@ -1177,11 +1176,11 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { let stackCoordinator = NavigationStackCoordinator() let params = LocationSharingScreenCoordinatorParameters(interactionMode: interactionMode, - mapURLBuilder: flowParameters.appSettings.mapTilerConfiguration.publisher.value, + mapURLBuilder: flowParameters.userSettings.mapTilerConfiguration.publisher.value, roomProxy: roomProxy, timelineController: timelineController, liveLocationManager: flowParameters.userSession.liveLocationManager, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, appMediator: flowParameters.appMediator, analytics: flowParameters.analytics, userIndicatorController: flowParameters.userIndicatorController, @@ -1326,7 +1325,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { userNotificationCenter: UNUserNotificationCenter.current(), userIndicatorController: flowParameters.userIndicatorController, isModallyPresented: true, - appSettings: flowParameters.appSettings) + userSettings: flowParameters.userSettings) let coordinator = NotificationSettingsScreenCoordinator(parameters: parameters) coordinator.actions.sink { [weak self] action in switch action { @@ -1421,7 +1420,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { let coordinator = SecurityAndPrivacyScreenCoordinator(parameters: .init(roomProxy: roomProxy, clientProxy: userSession.clientProxy, userIndicatorController: flowParameters.userIndicatorController, - appSetting: flowParameters.appSettings)) + appSetting: flowParameters.userSettings)) coordinator.actionsPublisher.sink { [weak self] action in guard let self else { return } diff --git a/ElementX/Sources/FlowCoordinators/SettingsFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/SettingsFlowCoordinator.swift index c8c1c6a64..6b7c63a98 100644 --- a/ElementX/Sources/FlowCoordinators/SettingsFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/SettingsFlowCoordinator.swift @@ -73,7 +73,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { private func presentSettingsScreen(animated: Bool) { let settingsScreenCoordinator = SettingsScreenCoordinator(parameters: .init(userSession: flowParameters.userSession, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, isBugReportServiceEnabled: flowParameters.bugReportService.isEnabled, isInSecondaryWindow: isInSecondaryWindow, userIndicatorController: flowParameters.userIndicatorController)) @@ -129,7 +129,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { } private func presentLabs() { - let coordinator = LabsScreenCoordinator(parameters: .init(appSettings: flowParameters.appSettings)) + let coordinator = LabsScreenCoordinator(parameters: .init(userSettings: flowParameters.userSettings)) coordinator.actions .sink { [weak self] action in switch action { @@ -144,7 +144,6 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { private func startEncryptionSettingsFlow() { let coordinator = EncryptionSettingsFlowCoordinator(parameters: .init(userSession: flowParameters.userSession, - appSettings: flowParameters.appSettings, appHooks: flowParameters.appHooks, userIndicatorController: flowParameters.userIndicatorController, navigationStackCoordinator: navigationStackCoordinator)) @@ -181,7 +180,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { private func presentUserDetailsEditScreen() { let coordinator = UserDetailsEditScreenCoordinator(parameters: .init(orientationManager: flowParameters.windowManager, userSession: flowParameters.userSession, - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: flowParameters.appSettings), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSettings), navigationStackCoordinator: navigationStackCoordinator, userIndicatorController: flowParameters.userIndicatorController)) coordinator.actions @@ -225,7 +224,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { } private func presentAnalyticsScreen() { - let coordinator = AnalyticsSettingsScreenCoordinator(parameters: .init(appSettings: flowParameters.appSettings, + let coordinator = AnalyticsSettingsScreenCoordinator(parameters: .init(userSettings: flowParameters.userSettings, analytics: flowParameters.analytics)) navigationStackCoordinator.push(coordinator) } @@ -251,11 +250,11 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { } private func presentLegalInformationScreen() { - navigationStackCoordinator.push(LegalInformationScreenCoordinator(appSettings: flowParameters.appSettings)) + navigationStackCoordinator.push(LegalInformationScreenCoordinator(userSettings: flowParameters.userSettings)) } private func presentBlockedUsersScreen() { - let coordinator = BlockedUsersScreenCoordinator(parameters: .init(hideProfiles: flowParameters.appSettings.hideIgnoredUserProfiles, + let coordinator = BlockedUsersScreenCoordinator(parameters: .init(hideProfiles: flowParameters.userSettings.hideIgnoredUserProfiles, userSession: flowParameters.userSession, userIndicatorController: flowParameters.userIndicatorController)) navigationStackCoordinator.push(coordinator) @@ -267,13 +266,13 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { userNotificationCenter: UNUserNotificationCenter.current(), userIndicatorController: flowParameters.userIndicatorController, isModallyPresented: false, - appSettings: flowParameters.appSettings) + userSettings: flowParameters.userSettings) let coordinator = NotificationSettingsScreenCoordinator(parameters: notificationParameters) navigationStackCoordinator.push(coordinator) } private func presentAdvancedSettings() { - let coordinator = AdvancedSettingsScreenCoordinator(parameters: .init(appSettings: flowParameters.appSettings, + let coordinator = AdvancedSettingsScreenCoordinator(parameters: .init(userSettings: flowParameters.userSettings, analytics: flowParameters.analytics, clientProxy: flowParameters.userSession.clientProxy, userIndicatorController: flowParameters.userIndicatorController)) @@ -281,7 +280,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { } private func presentDeveloperOptions() { - let coordinator = DeveloperOptionsScreenCoordinator(appSettings: flowParameters.appSettings, + let coordinator = DeveloperOptionsScreenCoordinator(appSettings: flowParameters.userSettings.app, appHooks: flowParameters.appHooks, clientProxy: flowParameters.userSession.clientProxy) @@ -327,7 +326,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { accountSettingsPresenter = OAuthAccountSettingsPresenter(accountURL: url, presentationAnchor: flowParameters.windowManager.mainWindow, appMediator: flowParameters.appMediator, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, appHooks: flowParameters.appHooks, continuation: continuation) accountSettingsPresenter?.start() diff --git a/ElementX/Sources/FlowCoordinators/SpaceFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/SpaceFlowCoordinator.swift index cc221ea68..aa63e11fe 100644 --- a/ElementX/Sources/FlowCoordinators/SpaceFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/SpaceFlowCoordinator.swift @@ -400,7 +400,7 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol { let parameters = JoinRoomScreenCoordinatorParameters(source: .space(spaceServiceRoom), userSession: flowParameters.userSession, userIndicatorController: flowParameters.userIndicatorController, - appSettings: flowParameters.appSettings) + userSettings: flowParameters.userSettings) let coordinator = JoinRoomScreenCoordinator(parameters: parameters) coordinator.actionsPublisher .sink { [weak self] action in diff --git a/ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift index 83a60f9b8..906448fe8 100644 --- a/ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift @@ -211,7 +211,7 @@ final class SpaceSettingsFlowCoordinator: FlowCoordinatorProtocol { private func presentSpaceSettings(animated: Bool) { let coordinator = RoomDetailsScreenCoordinator(parameters: .init(roomProxy: roomProxy, userSession: flowParameters.userSession, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, appHooks: flowParameters.appHooks, analyticsService: flowParameters.analytics, userIndicatorController: flowParameters.userIndicatorController, @@ -252,7 +252,7 @@ final class SpaceSettingsFlowCoordinator: FlowCoordinatorProtocol { let stackCoordinator = NavigationStackCoordinator() let parameters = RoomDetailsEditScreenCoordinatorParameters(roomProxy: roomProxy, userSession: flowParameters.userSession, - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: flowParameters.appSettings), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSettings), navigationStackCoordinator: stackCoordinator, userIndicatorController: flowParameters.userIndicatorController, orientationManager: flowParameters.appMediator.windowManager) @@ -278,7 +278,7 @@ final class SpaceSettingsFlowCoordinator: FlowCoordinatorProtocol { let coordinator = SecurityAndPrivacyScreenCoordinator(parameters: .init(roomProxy: roomProxy, clientProxy: flowParameters.userSession.clientProxy, userIndicatorController: flowParameters.userIndicatorController, - appSetting: flowParameters.appSettings)) + appSetting: flowParameters.userSettings)) coordinator.actionsPublisher.sink { [weak self] action in guard let self else { return } diff --git a/ElementX/Sources/FlowCoordinators/StartChatFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/StartChatFlowCoordinator.swift index 13a928c62..2d339d9bc 100644 --- a/ElementX/Sources/FlowCoordinators/StartChatFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/StartChatFlowCoordinator.swift @@ -214,7 +214,7 @@ class StartChatFlowCoordinator: FlowCoordinatorProtocol { shouldShowCancelButton: isRoot, userSession: flowParameters.userSession, userIndicatorController: flowParameters.userIndicatorController, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, analytics: flowParameters.analytics) let coordinator = CreateRoomScreenCoordinator(parameters: createParameters) coordinator.actions.sink { [weak self] action in diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 168f57941..5e3950b77 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -82,29 +82,29 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { self.appLockService = appLockService self.flowParameters = flowParameters presenceService = PresenceService(clientProxy: flowParameters.userSession.clientProxy, - appSettings: flowParameters.appSettings) + userSettings: flowParameters.userSettings) navigationTabCoordinator = NavigationTabCoordinator() navigationRootCoordinator.setRootCoordinator(navigationTabCoordinator) - let chatsSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.appSettings.hideBrandChrome)) + let chatsSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.userSettings.hideBrandChrome)) chatsTabFlowCoordinator = ChatsTabFlowCoordinator(navigationSplitCoordinator: chatsSplitCoordinator, flowParameters: flowParameters) chatsTabDetails = .init(tag: HomeTab.chats, title: L10n.screenHomeTabChats, icon: \.chat, selectedIcon: \.chatSolid) chatsTabDetails.navigationSplitCoordinator = chatsSplitCoordinator - let spacesSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.appSettings.hideBrandChrome)) + let spacesSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.userSettings.hideBrandChrome)) spacesTabFlowCoordinator = SpacesTabFlowCoordinator(navigationSplitCoordinator: spacesSplitCoordinator, flowParameters: flowParameters) spacesTabDetails = .init(tag: HomeTab.spaces, title: L10n.screenHomeTabSpaces, icon: \.space, selectedIcon: \.spaceSolid) spacesTabDetails.navigationSplitCoordinator = spacesSplitCoordinator - if flowParameters.appSettings.globalSearchEnabled, #available(iOS 26.0, *) { + if flowParameters.userSettings.globalSearchEnabled, #available(iOS 26.0, *) { let searchCoordinator = SearchScreenCoordinator(parameters: .init(roomSummaryProvider: flowParameters.userSession.clientProxy.alternateRoomSummaryProvider, clientProxy: flowParameters.userSession.clientProxy, mediaProvider: flowParameters.userSession.mediaProvider, userIndicatorController: flowParameters.userIndicatorController, - appSettings: flowParameters.appSettings)) + userSettings: flowParameters.userSettings)) let searchStackCoordinator = NavigationStackCoordinator() searchStackCoordinator.setRootCoordinator(searchCoordinator) @@ -425,7 +425,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController, flow: flow, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, mediaProvider: userSession.mediaProvider) let coordinator = SessionVerificationScreenCoordinator(parameters: parameters) @@ -463,8 +463,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { presentCallScreen(configuration: .init(roomProxy: roomProxy, clientProxy: userSession.clientProxy, clientID: InfoPlistReader.main.bundleIdentifier, - elementCallBaseURL: flowParameters.appSettings.elementCallBaseURL, - elementCallBaseURLOverride: flowParameters.appSettings.elementCallBaseURLOverride, + elementCallBaseURL: flowParameters.userSettings.elementCallBaseURL, + elementCallBaseURLOverride: flowParameters.userSettings.elementCallBaseURLOverride, voiceOnly: voiceOnly, colorScheme: colorScheme)) } @@ -486,7 +486,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { let callScreenCoordinator = CallScreenCoordinator(parameters: .init(elementCallService: flowParameters.elementCallService, configuration: configuration, allowPictureInPicture: true, - appSettings: flowParameters.appSettings, + userSettings: flowParameters.userSettings, analytics: flowParameters.analytics)) callScreenCoordinator.actions diff --git a/ElementX/Sources/Mocks/ClientFactoryMock.swift b/ElementX/Sources/Mocks/ClientFactoryMock.swift index e7d7d551e..a6dd4324b 100644 --- a/ElementX/Sources/Mocks/ClientFactoryMock.swift +++ b/ElementX/Sources/Mocks/ClientFactoryMock.swift @@ -64,7 +64,7 @@ extension ClientFactoryMock { ClientSDKMock(.init(userID: credentials.userID)) } - makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksClosure = { credentials, _, _, _, _ in + makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksClosure = { credentials, _, _, _, _ in ClientSDKMock(.init(userID: credentials.userID)) } } diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index 9eb3f99bb..c2caf235a 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -2346,48 +2346,48 @@ nonisolated class ClientFactoryMock: ClientFactoryProtocol, @unchecked Sendable } //MARK: - makeNSEClient - nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksThrowableError: Error? - private let makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksCallsCountLock = NSLock() - private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingCallsCount = 0 - var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksCallsCount: Int { - get { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksCallsCountLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingCallsCount } } - set { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksCallsCountLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingCallsCount = newValue } } + nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksThrowableError: Error? + private let makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksCallsCountLock = NSLock() + private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingCallsCount = 0 + var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksCallsCount: Int { + get { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksCallsCountLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingCallsCount } } + set { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksCallsCountLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingCallsCount = newValue } } } - var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksCalled: Bool { - return makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksCallsCount > 0 + var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksCalled: Bool { + return makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksCallsCount > 0 } - private let makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedArgumentsLock = NSLock() - private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReceivedArguments: (credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, appSettings: CommonSettingsProtocol, appHooks: AppHooks)? - var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedArguments: (credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, appSettings: CommonSettingsProtocol, appHooks: AppHooks)? { - get { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedArgumentsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReceivedArguments } } - set { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedArgumentsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReceivedArguments = newValue } } + private let makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedArgumentsLock = NSLock() + private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedArguments: (credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: CommonSettingsProtocol, appHooks: AppHooks)? + var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedArguments: (credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: CommonSettingsProtocol, appHooks: AppHooks)? { + get { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedArgumentsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedArguments } } + set { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedArgumentsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedArguments = newValue } } } - private let makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedInvocationsLock = NSLock() - private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReceivedInvocations: [(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, appSettings: CommonSettingsProtocol, appHooks: AppHooks)] = [] - var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedInvocations: [(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, appSettings: CommonSettingsProtocol, appHooks: AppHooks)] { - get { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedInvocationsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReceivedInvocations } } - set { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedInvocationsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReceivedInvocations = newValue } } + private let makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedInvocationsLock = NSLock() + private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedInvocations: [(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: CommonSettingsProtocol, appHooks: AppHooks)] = [] + var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedInvocations: [(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: CommonSettingsProtocol, appHooks: AppHooks)] { + get { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedInvocationsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedInvocations } } + set { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedInvocationsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedInvocations = newValue } } } - private let makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReturnValueLock = NSLock() - private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReturnValue: ClientProtocol! - var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReturnValue: ClientProtocol! { - get { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReturnValueLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReturnValue } } - set { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReturnValueLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReturnValue = newValue } } + private let makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReturnValueLock = NSLock() + private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReturnValue: ClientProtocol! + var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReturnValue: ClientProtocol! { + get { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReturnValueLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReturnValue } } + set { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReturnValueLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReturnValue = newValue } } } - nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksClosure: ((KeychainCredentials, String, ClientSessionDelegate, CommonSettingsProtocol, AppHooks) async throws -> ClientProtocol)? + nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksClosure: ((KeychainCredentials, String, ClientSessionDelegate, CommonSettingsProtocol, AppHooks) async throws -> ClientProtocol)? - @concurrent func makeNSEClient(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, appSettings: CommonSettingsProtocol, appHooks: AppHooks) async throws -> ClientProtocol { - if let error = makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksThrowableError { + @concurrent func makeNSEClient(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: CommonSettingsProtocol, appHooks: AppHooks) async throws -> ClientProtocol { + if let error = makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksThrowableError { throw error } - makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksCallsCountLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingCallsCount += 1 } - makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedArguments = (credentials: credentials, roomID: roomID, clientSessionDelegate: clientSessionDelegate, appSettings: appSettings, appHooks: appHooks) - makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReceivedInvocationsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksUnderlyingReceivedInvocations.append((credentials: credentials, roomID: roomID, clientSessionDelegate: clientSessionDelegate, appSettings: appSettings, appHooks: appHooks)) } - if let makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksClosure = makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksClosure { - return try await makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksClosure(credentials, roomID, clientSessionDelegate, appSettings, appHooks) + makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksCallsCountLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingCallsCount += 1 } + makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedArguments = (credentials: credentials, roomID: roomID, clientSessionDelegate: clientSessionDelegate, userSettings: userSettings, appHooks: appHooks) + makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedInvocationsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedInvocations.append((credentials: credentials, roomID: roomID, clientSessionDelegate: clientSessionDelegate, userSettings: userSettings, appHooks: appHooks)) } + if let makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksClosure = makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksClosure { + return try await makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksClosure(credentials, roomID, clientSessionDelegate, userSettings, appHooks) } else { - return makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksReturnValue + return makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReturnValue } } } @@ -14533,6 +14533,11 @@ nonisolated class UserSessionMock: UserSessionProtocol, @unchecked Sendable { set(value) { underlyingClientProxy = value } } nonisolated(unsafe) var underlyingClientProxy: ClientProxyProtocol! + var userSettings: UserSettings { + get { return underlyingUserSettings } + set(value) { underlyingUserSettings = value } + } + nonisolated(unsafe) var underlyingUserSettings: UserSettings! var mediaProvider: MediaProviderProtocol { get { return underlyingMediaProvider } set(value) { underlyingMediaProvider = value } diff --git a/ElementX/Sources/Mocks/UserSessionMock.swift b/ElementX/Sources/Mocks/UserSessionMock.swift index 2533fc1af..24d556bc8 100644 --- a/ElementX/Sources/Mocks/UserSessionMock.swift +++ b/ElementX/Sources/Mocks/UserSessionMock.swift @@ -11,6 +11,7 @@ import Foundation struct UserSessionMockConfiguration { var clientProxy: ClientProxyProtocol = ClientProxyMock(.init()) + var userSettings: UserSettings = .volatile() var contentScannerService: ContentScannerServiceProtocol? } @@ -19,6 +20,8 @@ struct UserSessionMockConfiguration { self.init() clientProxy = configuration.clientProxy + userSettings = configuration.userSettings + mediaProvider = MediaProviderMock(.init()) voiceMessageMediaManager = VoiceMessageMediaManagerMock() contentScannerService = configuration.contentScannerService diff --git a/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift b/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift index 342a78ab8..bf948fdc2 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift @@ -56,7 +56,7 @@ private struct VisualListItemLabelStyle: LabelStyle { // MARK: - Previews struct VisualListItem_Previews: PreviewProvider, TestablePreview { - static let strings = AnalyticsPromptScreenStrings(termsURL: AppSettings.volatile().analyticsTermsURL) + static let strings = AnalyticsPromptScreenStrings(termsURL: UserSettings.volatile().analyticsTermsURL) static var testImage1: some View { Image(systemName: "circle") diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift b/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift index d81522216..2f184bb32 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenCoordinator.swift @@ -14,7 +14,7 @@ struct CallScreenCoordinatorParameters { let elementCallService: ElementCallServiceProtocol let configuration: ElementCallConfiguration let allowPictureInPicture: Bool - let appSettings: AppSettings + let userSettings: UserSettings let analytics: AnalyticsServiceProtocol } @@ -45,7 +45,7 @@ final class CallScreenCoordinator: CoordinatorProtocol { viewModel = CallScreenViewModel(elementCallService: parameters.elementCallService, configuration: parameters.configuration, allowPictureInPicture: parameters.allowPictureInPicture, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, analyticsService: parameters.analytics) } diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift index 1a0299480..68772af4c 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift @@ -17,7 +17,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol private let elementCallService: ElementCallServiceProtocol private let configuration: ElementCallConfiguration private let isPictureInPictureAllowed: Bool - private let appSettings: AppSettings + private let userSettings: UserSettings private let analyticsService: AnalyticsServiceProtocol private let widgetDriver: ElementCallWidgetDriverProtocol @@ -39,11 +39,11 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol init(elementCallService: ElementCallServiceProtocol, configuration: ElementCallConfiguration, allowPictureInPicture: Bool, - appSettings: AppSettings, + userSettings: UserSettings, analyticsService: AnalyticsServiceProtocol) { self.elementCallService = elementCallService self.configuration = configuration - self.appSettings = appSettings + self.userSettings = userSettings self.analyticsService = analyticsService isPictureInPictureAllowed = allowPictureInPicture @@ -165,13 +165,13 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol // We only set the analytics configuration if analytics are enabled let analyticsConfiguration: ElementCallAnalyticsConfiguration? = if analyticsService.isEnabled { - .init(posthogAPIHost: appSettings.elementCallPosthogAPIHost, - posthogAPIKey: appSettings.elementCallPosthogAPIKey, - sentryDSN: appSettings.elementCallPosthogSentryDSN) + .init(posthogAPIHost: userSettings.elementCallPosthogAPIHost, + posthogAPIKey: userSettings.elementCallPosthogAPIKey, + sentryDSN: userSettings.elementCallPosthogSentryDSN) } else { nil } - let rageshakeURL: String? = if case let .url(baseURL) = appSettings.bugReportRageshakeURL.publisher.value { + let rageshakeURL: String? = if case let .url(baseURL) = userSettings.bugReportRageshakeURL.publisher.value { baseURL.absoluteString } else { nil diff --git a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift index 12912d44c..e90d1f9a3 100644 --- a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift +++ b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift @@ -405,7 +405,7 @@ struct CallScreen_Previews: PreviewProvider { voiceOnly: false, colorScheme: .light), allowPictureInPicture: false, - appSettings: .volatile(), + userSettings: .volatile(), analyticsService: AnalyticsServiceMock(.init())) } } diff --git a/ElementX/Sources/Screens/CreateRoomScreen/CreateRoomScreenCoordinator.swift b/ElementX/Sources/Screens/CreateRoomScreen/CreateRoomScreenCoordinator.swift index 11552a256..26bd998aa 100644 --- a/ElementX/Sources/Screens/CreateRoomScreen/CreateRoomScreenCoordinator.swift +++ b/ElementX/Sources/Screens/CreateRoomScreen/CreateRoomScreenCoordinator.swift @@ -15,7 +15,7 @@ struct CreateRoomScreenCoordinatorParameters { let shouldShowCancelButton: Bool let userSession: UserSessionProtocol let userIndicatorController: UserIndicatorControllerProtocol - let appSettings: AppSettings + let userSettings: UserSettings let analytics: AnalyticsServiceProtocol } @@ -41,7 +41,7 @@ final class CreateRoomScreenCoordinator: CoordinatorProtocol { userSession: parameters.userSession, analytics: parameters.analytics, userIndicatorController: parameters.userIndicatorController, - appSettings: parameters.appSettings) + userSettings: parameters.userSettings) } func start() { diff --git a/ElementX/Sources/Screens/CreateRoomScreen/CreateRoomScreenViewModel.swift b/ElementX/Sources/Screens/CreateRoomScreen/CreateRoomScreenViewModel.swift index 695ad33c2..913e5473a 100644 --- a/ElementX/Sources/Screens/CreateRoomScreen/CreateRoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/CreateRoomScreen/CreateRoomScreenViewModel.swift @@ -33,9 +33,9 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen userSession: UserSessionProtocol, analytics: AnalyticsServiceProtocol, userIndicatorController: UserIndicatorControllerProtocol, - appSettings: AppSettings) { + userSettings: UserSettings) { self.userSession = userSession - mediaUploadingPreprocessor = MediaUploadingPreprocessor(appSettings: appSettings) + mediaUploadingPreprocessor = MediaUploadingPreprocessor(userSettings: userSettings) self.analytics = analytics self.userIndicatorController = userIndicatorController @@ -63,7 +63,7 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen shouldShowCancelButton: shouldShowCancelButton, roomName: "", serverName: userSession.clientProxy.userIDServerName ?? "", - isKnockingFeatureEnabled: appSettings.knockingEnabled, + isKnockingFeatureEnabled: userSettings.knockingEnabled, canSelectSpace: canSelectSpace, aliasLocalPart: roomAliasNameFromRoomDisplayName(roomName: ""), bindings: bindings), diff --git a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift index c20dc4e44..968eb155a 100644 --- a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift +++ b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift @@ -451,8 +451,8 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview { isSpace: Bool = false, selectionMode: CreateRoomScreenSpaceSelectionMode = .editableSpacesList(preSelectedSpace: nil), isAliasAvailable: Bool = true) -> CreateRoomScreenViewModel { - let appSettings = AppSettings.volatile() - appSettings.knockingEnabled = isKnockingEnabled + let userSettings = UserSettings.volatile() + userSettings.knockingEnabled = isKnockingEnabled let clientProxy = ClientProxyMock(.init(userIDServerName: "example.org", userID: "@userid:example.com")) @@ -467,6 +467,6 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview { userSession: userSession, analytics: AnalyticsServiceMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: appSettings) + userSettings: userSettings) } } diff --git a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift index 4e5dcab68..e3f39bd07 100644 --- a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift +++ b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift @@ -65,7 +65,7 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview clientProxy.spaceService = SpaceServiceProxyMock(.init(editableSpaces: .mockJoinedSpaces2)) let userSession = UserSessionMock(.init(clientProxy: clientProxy)) - let appSettings = AppSettings.volatile() + let userSettings = UserSettings.volatile() return CreateRoomScreenViewModel(isSpace: false, spaceSelectionMode: .editableSpacesList(preSelectedSpace: nil), @@ -73,7 +73,7 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview userSession: userSession, analytics: AnalyticsServiceMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: appSettings) + userSettings: userSettings) }() static var previews: some View { diff --git a/ElementX/Sources/Screens/EmojiPickerScreen/View/EmojiPickerScreen.swift b/ElementX/Sources/Screens/EmojiPickerScreen/View/EmojiPickerScreen.swift index b5fba7831..1f0dd12e1 100644 --- a/ElementX/Sources/Screens/EmojiPickerScreen/View/EmojiPickerScreen.swift +++ b/ElementX/Sources/Screens/EmojiPickerScreen/View/EmojiPickerScreen.swift @@ -103,7 +103,7 @@ struct EmojiPickerScreen: View { @available(iOS 26.0, *) struct EmojiPickerScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = EmojiPickerScreenViewModel(selectedEmojis: ["😀", "😄"], - emojiProvider: EmojiProvider(appSettings: .volatile()), + emojiProvider: EmojiProvider(userSettings: .volatile()), continuation: AsyncStream.makeStream().continuation) static var previews: some View { @@ -115,7 +115,7 @@ struct EmojiPickerScreen_Previews: PreviewProvider, TestablePreview { struct EmojiPickerScreenSheet_Previews: PreviewProvider { static let viewModel = EmojiPickerScreenViewModel(selectedEmojis: ["😀", "😄"], - emojiProvider: EmojiProvider(appSettings: .volatile()), + emojiProvider: EmojiProvider(userSettings: .volatile()), continuation: AsyncStream.makeStream().continuation) static var previews: some View { diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift index b039d7fdb..70e904f8f 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift @@ -13,7 +13,7 @@ struct HomeScreenCoordinatorParameters { let userSession: UserSessionProtocol let bugReportService: BugReportServiceProtocol let selectedRoomPublisher: CurrentValuePublisher - let appSettings: AppSettings + let userSettings: UserSettings let analyticsService: AnalyticsServiceProtocol let notificationManager: NotificationManagerProtocol let userIndicatorController: UserIndicatorControllerProtocol @@ -50,7 +50,7 @@ final class HomeScreenCoordinator: CoordinatorProtocol { init(parameters: HomeScreenCoordinatorParameters) { viewModel = HomeScreenViewModel(userSession: parameters.userSession, selectedRoomPublisher: parameters.selectedRoomPublisher, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, analyticsService: parameters.analyticsService, bugReportService: parameters.bugReportService, notificationManager: parameters.notificationManager, diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift index d97321eed..f5738dd40 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift @@ -18,7 +18,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol private let spaceFilterSubject: CurrentValueSubject private let analyticsService: AnalyticsServiceProtocol private let bugReportService: BugReportServiceProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let notificationManager: NotificationManagerProtocol private let userIndicatorController: UserIndicatorControllerProtocol @@ -32,7 +32,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol // swiftlint:disable:next function_body_length init(userSession: UserSessionProtocol, selectedRoomPublisher: CurrentValuePublisher, - appSettings: AppSettings, + userSettings: UserSettings, analyticsService: AnalyticsServiceProtocol, bugReportService: BugReportServiceProtocol, notificationManager: NotificationManagerProtocol, @@ -40,7 +40,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol self.userSession = userSession self.analyticsService = analyticsService self.bugReportService = bugReportService - self.appSettings = appSettings + self.userSettings = userSettings self.notificationManager = notificationManager self.userIndicatorController = userIndicatorController @@ -49,10 +49,10 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol roomSummaryProvider = userSession.clientProxy.roomSummaryProvider super.init(initialViewState: .init(userProfile: userSession.clientProxy.userProfilePublisher.value, - bindings: .init(filtersState: .init(appSettings: appSettings))), + bindings: .init(filtersState: .init(userSettings: userSettings))), mediaProvider: userSession.mediaProvider) - if appSettings.globalSearchEnabled, #available(iOS 26.0, *) { + if userSettings.globalSearchEnabled, #available(iOS 26.0, *) { state.isRoomListSearchEnabled = false } @@ -113,21 +113,21 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol .weakAssign(to: \.state.selectedRoomID, on: self) .store(in: &cancellables) - appSettings.showAllRoomListActivityPublisher + userSettings.showAllRoomListActivityPublisher .removeDuplicates() .sink { [weak self] _ in self?.updateRooms() } .store(in: &cancellables) - appSettings.seenInvitesPublisher + userSettings.seenInvitesPublisher .removeDuplicates() .sink { [weak self] _ in self?.updateRooms() } .store(in: &cancellables) - appSettings.hasSeenNewSoundBannerPublisher + userSettings.hasSeenNewSoundBannerPublisher .sink { [weak self] hasSeenNewSoundBanner in self?.state.shouldShowNewSoundBanner = !hasSeenNewSoundBanner } @@ -210,7 +210,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol case .skipRecoveryKeyConfirmation: state.securityBannerMode = .dismissed case .dismissNewSoundBanner: - appSettings.hasSeenNewSoundBanner = true + userSettings.hasSeenNewSoundBanner = true case .updateVisibleItemRange(let range): roomSummaryProvider?.updateVisibleRange(range) case .startChat: @@ -260,7 +260,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol case .success: analyticsService.trackInteraction(name: .MobileRoomListRoomContextMenuUnreadToggle) - if case .failure(let error) = await roomProxy.markAsRead(receiptType: appSettings.sharePresence ? .read : .readPrivate) { + if case .failure(let error) = await roomProxy.markAsRead(receiptType: userSettings.sharePresence ? .read : .readPrivate) { MXLog.error("Failed marking room \(roomIdentifier) as read with error: \(error)") } case .failure(let error): @@ -372,11 +372,11 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol } var rooms = [HomeScreenRoom]() - let seenInvites = appSettings.seenInvites + let seenInvites = userSettings.seenInvites for summary in roomSummaryProvider.roomListPublisher.value { let room = HomeScreenRoom(summary: summary, - showAllActivity: appSettings.showAllRoomListActivity, + showAllActivity: userSettings.showAllRoomListActivity, seenInvites: seenInvites) rooms.append(room) } @@ -513,7 +513,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol analyticsService.trackJoinedRoom(isDM: roomProxy.info.isDirect, isSpace: roomProxy.info.isSpace, activeMemberCount: UInt(roomProxy.info.activeMembersCount)) - appSettings.seenInvites.remove(roomProxy.id) + userSettings.seenInvites.remove(roomProxy.id) } private func showDeclineInviteConfirmationAlert(roomID: String) async { @@ -563,7 +563,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol switch result { case .success: await notificationManager.removeDeliveredMessageNotifications(for: roomID) // Normally handled by the room flow, but that's never presented in this case. - appSettings.seenInvites.remove(roomID) + userSettings.seenInvites.remove(roomID) case .failure: displayError() } diff --git a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFilterModels.swift b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFilterModels.swift index 9d9ea9f80..86083af89 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFilterModels.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFilterModels.swift @@ -89,21 +89,21 @@ enum RoomListFilter: Int, CaseIterable, Identifiable { struct RoomListFiltersState { private(set) var activeFilters: OrderedSet - private let appSettings: AppSettings + private let userSettings: UserSettings - init(activeFilters: OrderedSet = [], appSettings: AppSettings) { + init(activeFilters: OrderedSet = [], userSettings: UserSettings) { self.activeFilters = .init(activeFilters) - self.appSettings = appSettings + self.userSettings = userSettings } var availableFilters: [RoomListFilter] { var availableFilters = OrderedSet(RoomListFilter.availableFilters) - if !appSettings.lowPriorityFilterEnabled { + if !userSettings.lowPriorityFilterEnabled { availableFilters.remove(.lowPriority) } - if !appSettings.mentionsFilterEnabled { + if !userSettings.mentionsFilterEnabled { availableFilters.remove(.mentions) } diff --git a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersEmptyStateView.swift b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersEmptyStateView.swift index 4d7a78d72..414da9004 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersEmptyStateView.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersEmptyStateView.swift @@ -61,10 +61,10 @@ struct RoomListFiltersEmptyStateView_Previews: PreviewProvider, TestablePreview VStack(spacing: 24) { ForEach(RoomListFilter.allCases) { filter in RoomListFiltersEmptyStateView(state: .init(activeFilters: [filter], - appSettings: .volatile())) + userSettings: .volatile())) } RoomListFiltersEmptyStateView(state: .init(activeFilters: [.people, .favourites], - appSettings: .volatile())) + userSettings: .volatile())) } .padding(.bottom) .previewLayout(.sizeThatFits) diff --git a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift index 1a352bcf2..f71c0bdf1 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift @@ -92,10 +92,10 @@ struct RoomListFiltersView: View { struct RoomListFiltersView_Previews: PreviewProvider, TestablePreview { static var previews: some View { - RoomListFiltersView(state: .constant(.init(appSettings: .volatile()))) + RoomListFiltersView(state: .constant(.init(userSettings: .volatile()))) RoomListFiltersView(state: .constant(.init(activeFilters: [.rooms, .favourites], - appSettings: .volatile()))) + userSettings: .volatile()))) RoomListFiltersView(state: .constant(.init(activeFilters: [.lowPriority], - appSettings: .volatile()))) + userSettings: .volatile()))) } } diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift index b7b26380f..ca8397708 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift @@ -234,7 +234,7 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview { return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: .volatile(), + userSettings: .volatile(), analyticsService: AnalyticsServiceMock(.init()), bugReportService: BugReportServiceMock(.init()), notificationManager: NotificationManagerMock(), diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift index 78671b5a9..1483cfb33 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift @@ -145,7 +145,7 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview { roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))))))) return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: .volatile(), + userSettings: .volatile(), analyticsService: AnalyticsServiceMock(.init()), bugReportService: BugReportServiceMock(.init()), notificationManager: NotificationManagerMock(), diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift index b942e5cc9..efe412675 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift @@ -201,7 +201,7 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview { return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: .volatile(), + userSettings: .volatile(), analyticsService: AnalyticsServiceMock(.init()), bugReportService: BugReportServiceMock(.init()), notificationManager: NotificationManagerMock(), diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift index 7d279f470..93f16192e 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift @@ -133,7 +133,7 @@ struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview { return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: .volatile(), + userSettings: .volatile(), analyticsService: AnalyticsServiceMock(.init()), bugReportService: BugReportServiceMock(.init()), notificationManager: NotificationManagerMock(), diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift index 1a21241a1..d3d181079 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift @@ -122,7 +122,7 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: .volatile(), + userSettings: .volatile(), analyticsService: AnalyticsServiceMock(.init()), bugReportService: BugReportServiceMock(.init()), notificationManager: NotificationManagerMock(), diff --git a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenCoordinator.swift b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenCoordinator.swift index 321dd0e59..7447741d9 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenCoordinator.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenCoordinator.swift @@ -13,7 +13,7 @@ struct JoinRoomScreenCoordinatorParameters { let source: JoinRoomScreenSource let userSession: UserSessionProtocol let userIndicatorController: UserIndicatorControllerProtocol - let appSettings: AppSettings + let userSettings: UserSettings } enum JoinRoomScreenSource { @@ -53,7 +53,7 @@ final class JoinRoomScreenCoordinator: CoordinatorProtocol { init(parameters: JoinRoomScreenCoordinatorParameters) { viewModel = JoinRoomScreenViewModel(source: parameters.source, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, userSession: parameters.userSession, userIndicatorController: parameters.userIndicatorController) } diff --git a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift index 14bf12612..34940d65e 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift @@ -14,7 +14,7 @@ typealias JoinRoomScreenViewModelType = StateStoreViewModel() init(parameters: LabsScreenCoordinatorParameters) { - viewModel = LabsScreenViewModel(labsOptions: parameters.appSettings) + viewModel = LabsScreenViewModel(labsOptions: parameters.userSettings.app) } func start() { diff --git a/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenCoordinator.swift b/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenCoordinator.swift index 0d9926a50..305d54747 100644 --- a/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenCoordinator.swift +++ b/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenCoordinator.swift @@ -15,7 +15,7 @@ struct LocationSharingScreenCoordinatorParameters { let roomProxy: JoinedRoomProxyProtocol let timelineController: TimelineControllerProtocol let liveLocationManager: LiveLocationManagerProtocol - let appSettings: AppSettings + let userSettings: UserSettings let appMediator: AppMediatorProtocol let analytics: AnalyticsServiceProtocol let userIndicatorController: UserIndicatorControllerProtocol @@ -45,7 +45,7 @@ final class LocationSharingScreenCoordinator: CoordinatorProtocol { roomProxy: parameters.roomProxy, timelineController: parameters.timelineController, liveLocationManager: parameters.liveLocationManager, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, analytics: parameters.analytics, userIndicatorController: parameters.userIndicatorController, mediaProvider: parameters.mediaProvider) diff --git a/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift b/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift index c2b56dedd..e5e5e798c 100644 --- a/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift +++ b/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift @@ -17,7 +17,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati private let roomProxy: JoinedRoomProxyProtocol private let timelineController: TimelineControllerProtocol private let liveLocationManager: LiveLocationManagerProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let analytics: AnalyticsServiceProtocol private let userIndicatorController: UserIndicatorControllerProtocol private let notificationCenter: NotificationCenter @@ -37,7 +37,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati roomProxy: JoinedRoomProxyProtocol, timelineController: TimelineControllerProtocol, liveLocationManager: LiveLocationManagerProtocol, - appSettings: AppSettings, + userSettings: UserSettings, analytics: AnalyticsServiceProtocol, userIndicatorController: UserIndicatorControllerProtocol, mediaProvider: MediaProviderProtocol, @@ -45,7 +45,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati self.roomProxy = roomProxy self.timelineController = timelineController self.liveLocationManager = liveLocationManager - self.appSettings = appSettings + self.userSettings = userSettings self.analytics = analytics self.userIndicatorController = userIndicatorController self.notificationCenter = notificationCenter @@ -173,7 +173,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati } .store(in: &cancellables) - appSettings.liveLocationSharingSessionsByRoomIDPublisher + userSettings.liveLocationSharingSessionsByRoomIDPublisher .map { [roomID = roomProxy.id] sessions in sessions[roomID] != nil } .removeDuplicates() .sink { [weak self] isSharingLiveLocationOnThisDevice in @@ -261,14 +261,14 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati } private func showLiveLocationFlow() { - if appSettings.liveLocationDisclaimerDisplayed { + if userSettings.liveLocationDisclaimerDisplayed { showLiveLocationDurationPicker() } else { state.bindings.alertInfo = .init(alertID: .liveLocationDisclaimer, primaryButton: .init(title: L10n.actionDecline, role: .cancel, action: nil), secondaryButton: .init(title: L10n.actionAccept) { [weak self] in guard let self else { return } - appSettings.liveLocationDisclaimerDisplayed = true + userSettings.liveLocationDisclaimerDisplayed = true // Delay so SwiftUI finishes dismissing the current alert // before presenting the next one. DispatchQueue.main.async { @@ -432,14 +432,14 @@ extension LocationSharingScreenViewModel { let roomProxy = JoinedRoomProxyMock(.init(members: .allMembers, ownUserID: RoomMemberProxyMock.mockMe.userID)) roomProxy.makeLiveLocationServiceReturnValue = liveLocationServiceMock - let appSettings = AppSettings.volatile() + let userSettings = UserSettings.volatile() return LocationSharingScreenViewModel(interactionMode: interactionMode, - mapURLBuilder: appSettings.mapTilerConfiguration.publisher.value, + mapURLBuilder: userSettings.mapTilerConfiguration.publisher.value, roomProxy: roomProxy, timelineController: TimelineControllerMock(.init()), liveLocationManager: LiveLocationManagerMock(), - appSettings: appSettings, + userSettings: userSettings, analytics: AnalyticsServiceMock(.init()), userIndicatorController: UserIndicatorControllerMock(), mediaProvider: MediaProviderMock(.init())) diff --git a/ElementX/Sources/Screens/MediaEventsTimelineScreen/MediaEventsTimelineScreenCoordinator.swift b/ElementX/Sources/Screens/MediaEventsTimelineScreen/MediaEventsTimelineScreenCoordinator.swift index 9f9f6d32f..acb809315 100644 --- a/ElementX/Sources/Screens/MediaEventsTimelineScreen/MediaEventsTimelineScreenCoordinator.swift +++ b/ElementX/Sources/Screens/MediaEventsTimelineScreen/MediaEventsTimelineScreenCoordinator.swift @@ -16,7 +16,7 @@ struct MediaEventsTimelineScreenCoordinatorParameters { let userSession: UserSessionProtocol let mediaPlayerProvider: MediaPlayerProviderProtocol let appMediator: AppMediatorProtocol - let appSettings: AppSettings + let userSettings: UserSettings let analytics: AnalyticsServiceProtocol let emojiProvider: EmojiProviderProtocol let linkMetadataProvider: LinkMetadataProviderProtocol @@ -46,7 +46,6 @@ final class MediaEventsTimelineScreenCoordinator: CoordinatorProtocol { mediaPlayerProvider: parameters.mediaPlayerProvider, userIndicatorController: parameters.userIndicatorController, appMediator: parameters.appMediator, - appSettings: parameters.appSettings, analyticsService: parameters.analytics, emojiProvider: parameters.emojiProvider, linkMetadataProvider: parameters.linkMetadataProvider, @@ -58,7 +57,6 @@ final class MediaEventsTimelineScreenCoordinator: CoordinatorProtocol { mediaPlayerProvider: parameters.mediaPlayerProvider, userIndicatorController: parameters.userIndicatorController, appMediator: parameters.appMediator, - appSettings: parameters.appSettings, analyticsService: parameters.analytics, emojiProvider: parameters.emojiProvider, linkMetadataProvider: parameters.linkMetadataProvider, diff --git a/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift b/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift index 54b929e93..5ab8a5c3f 100644 --- a/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift +++ b/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift @@ -307,16 +307,14 @@ struct MediaEventsTimelineScreen_Previews: PreviewProvider, TestablePreview { makeTimelineController(screenMode: screenMode) } - let appSettings = AppSettings.volatile() return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room")), timelineController: timelineController, userSession: UserSessionMock(.init(contentScannerService: contentScannerService)), mediaPlayerProvider: MediaPlayerProviderMock(), userIndicatorController: UserIndicatorControllerMock(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), timelineControllerFactory: TimelineControllerFactoryMock(.init())) } diff --git a/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift b/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift index 650ad9b1a..b9f034846 100644 --- a/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift +++ b/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift @@ -393,7 +393,7 @@ struct MediaUploadPreviewScreen_Previews: PreviewProvider, TestablePreview { title: "App Icon.png", shouldShowCaptionWarning: true, galleryEnabled: true, - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: .volatile()), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: .volatile()), timelineController: TimelineControllerMock(.init()), clientProxy: ClientProxyMock(.init()), userIndicatorController: UserIndicatorControllerMock()) diff --git a/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift b/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift index cb1e18131..b5c19445e 100644 --- a/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift @@ -102,6 +102,6 @@ struct AnalyticsPromptScreen_Previews: PreviewProvider, TestablePreview { } static func makeViewModel(showTerms: Bool = true) -> AnalyticsPromptScreenViewModel { - AnalyticsPromptScreenViewModel(termsURL: showTerms ? AppSettings.volatile().analyticsTermsURL : nil) + AnalyticsPromptScreenViewModel(termsURL: showTerms ? UserSettings.volatile().analyticsTermsURL : nil) } } diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenCoordinator.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenCoordinator.swift index 95277a21e..e357aed47 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenCoordinator.swift @@ -11,7 +11,7 @@ import SwiftUI struct IdentityConfirmationScreenCoordinatorParameters { let userSession: UserSessionProtocol - let appSettings: AppSettings + let userSettings: UserSettings let userIndicatorController: UserIndicatorControllerProtocol } @@ -36,7 +36,7 @@ final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol { init(parameters: IdentityConfirmationScreenCoordinatorParameters) { viewModel = IdentityConfirmationScreenViewModel(userSession: parameters.userSession, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, userIndicatorController: parameters.userIndicatorController) } diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenViewModel.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenViewModel.swift index 0d55b9385..e2035a5cc 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenViewModel.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/IdentityConfirmationScreenViewModel.swift @@ -20,11 +20,11 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy actionsSubject.eraseToAnyPublisher() } - init(userSession: UserSessionProtocol, appSettings: AppSettings, userIndicatorController: UserIndicatorControllerProtocol) { + init(userSession: UserSessionProtocol, userSettings: UserSettings, userIndicatorController: UserIndicatorControllerProtocol) { self.userSession = userSession self.userIndicatorController = userIndicatorController - super.init(initialViewState: IdentityConfirmationScreenViewState(learnMoreURL: appSettings.deviceVerificationURL)) + super.init(initialViewState: IdentityConfirmationScreenViewState(learnMoreURL: userSettings.deviceVerificationURL)) Task { [weak self] in for await state in userSession.sessionSecurityStatePublisher.values { diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift index 6cec258e6..3bcd5987f 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift @@ -142,7 +142,7 @@ struct IdentityConfirmationScreen_Previews: PreviewProvider, TestablePreview { userSession.sessionSecurityStatePublisher = CurrentValuePublisher(.init(verificationState: .unverified, recoveryState: recoveryState)) return IdentityConfirmationScreenViewModel(userSession: userSession, - appSettings: .volatile(), + userSettings: .volatile(), userIndicatorController: UserIndicatorControllerMock()) } } diff --git a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/SessionVerificationScreenCoordinator.swift b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/SessionVerificationScreenCoordinator.swift index 7d96dbb22..b269fdd63 100644 --- a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/SessionVerificationScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/SessionVerificationScreenCoordinator.swift @@ -33,7 +33,7 @@ enum SessionVerificationScreenFlow { struct SessionVerificationScreenCoordinatorParameters { let sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol let flow: SessionVerificationScreenFlow - let appSettings: AppSettings + let userSettings: UserSettings let mediaProvider: MediaProviderProtocol } @@ -50,7 +50,7 @@ final class SessionVerificationScreenCoordinator: CoordinatorProtocol { init(parameters: SessionVerificationScreenCoordinatorParameters) { viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: parameters.sessionVerificationControllerProxy, flow: parameters.flow, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, mediaProvider: parameters.mediaProvider) } diff --git a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/SessionVerificationScreenViewModel.swift b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/SessionVerificationScreenViewModel.swift index c438b6f84..3765e05f5 100644 --- a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/SessionVerificationScreenViewModel.swift +++ b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/SessionVerificationScreenViewModel.swift @@ -25,7 +25,7 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess init(sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol, flow: SessionVerificationScreenFlow, - appSettings: AppSettings, + userSettings: UserSettings, mediaProvider: MediaProviderProtocol, verificationState: SessionVerificationScreenStateMachine.State = .initial) { self.sessionVerificationControllerProxy = sessionVerificationControllerProxy @@ -34,7 +34,7 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess stateMachine = SessionVerificationScreenStateMachine(state: verificationState) super.init(initialViewState: .init(flow: flow, - learnMoreURL: appSettings.encryptionURL, + learnMoreURL: userSettings.encryptionURL, verificationState: verificationState), mediaProvider: mediaProvider) diff --git a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift index fc7675096..0eca669e5 100644 --- a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift @@ -289,7 +289,7 @@ struct SessionVerification_Previews: PreviewProvider, TestablePreview { flow: SessionVerificationScreenFlow = .deviceInitiator) -> some View { let viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: SessionVerificationControllerProxyMock.configureMock(), flow: flow, - appSettings: .volatile(), + userSettings: .volatile(), mediaProvider: MediaProviderMock(.init()), verificationState: state) diff --git a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenCoordinator.swift b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenCoordinator.swift index 97e9eddeb..aa9d4418e 100644 --- a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenCoordinator.swift +++ b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenCoordinator.swift @@ -15,7 +15,7 @@ struct PinnedEventsTimelineScreenCoordinatorParameters { let userSession: UserSessionProtocol let mediaPlayerProvider: MediaPlayerProviderProtocol let appMediator: AppMediatorProtocol - let appSettings: AppSettings + let userSettings: UserSettings let analytics: AnalyticsServiceProtocol let emojiProvider: EmojiProviderProtocol let linkMetadataProvider: LinkMetadataProviderProtocol @@ -46,7 +46,7 @@ final class PinnedEventsTimelineScreenCoordinator: CoordinatorProtocol { init(parameters: PinnedEventsTimelineScreenCoordinatorParameters) { viewModel = PinnedEventsTimelineScreenViewModel(roomProxy: parameters.roomProxy, userIndicatorController: parameters.userIndicatorController, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, analyticsService: parameters.analytics) timelineViewModel = TimelineViewModel(roomProxy: parameters.roomProxy, timelineController: parameters.timelineController, @@ -54,7 +54,6 @@ final class PinnedEventsTimelineScreenCoordinator: CoordinatorProtocol { mediaPlayerProvider: parameters.mediaPlayerProvider, userIndicatorController: parameters.userIndicatorController, appMediator: parameters.appMediator, - appSettings: parameters.appSettings, analyticsService: parameters.analytics, emojiProvider: parameters.emojiProvider, linkMetadataProvider: parameters.linkMetadataProvider, diff --git a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenViewModel.swift b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenViewModel.swift index 894601880..fff7e7294 100644 --- a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenViewModel.swift +++ b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/PinnedEventsTimelineScreenViewModel.swift @@ -14,7 +14,7 @@ typealias PinnedEventsTimelineScreenViewModelType = StateStoreViewModel = .init() @@ -24,11 +24,11 @@ class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelTy init(roomProxy: JoinedRoomProxyProtocol, userIndicatorController: UserIndicatorControllerProtocol, - appSettings: AppSettings, + userSettings: UserSettings, analyticsService: AnalyticsServiceProtocol) { self.roomProxy = roomProxy self.userIndicatorController = userIndicatorController - self.appSettings = appSettings + self.userSettings = userSettings self.analyticsService = analyticsService super.init(initialViewState: PinnedEventsTimelineScreenViewState()) } @@ -77,7 +77,7 @@ class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelTy private func viewInRoomTimeline(eventID: String) async { switch await roomProxy.loadOrFetchEventDetails(for: eventID) { case .success(let event): - let threadRootEventID: String? = if appSettings.threadsEnabled { + let threadRootEventID: String? = if userSettings.threadsEnabled { event.threadRootEventId() } else { nil diff --git a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift index 107a39f12..5b2b4f453 100644 --- a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift +++ b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift @@ -83,7 +83,7 @@ struct PinnedEventsTimelineScreen: View { struct PinnedEventsTimelineScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = PinnedEventsTimelineScreenViewModel(roomProxy: JoinedRoomProxyMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: .volatile(), + userSettings: .volatile(), analyticsService: AnalyticsServiceMock(.init())) static let emptyTimelineViewModel = makeTimelineViewModel(timelineItems: []) diff --git a/ElementX/Sources/Screens/QRCodeLoginScreen/QRCodeLoginScreenModels.swift b/ElementX/Sources/Screens/QRCodeLoginScreen/QRCodeLoginScreenModels.swift index 1ffdd7f7e..4cb24c325 100644 --- a/ElementX/Sources/Screens/QRCodeLoginScreen/QRCodeLoginScreenModels.swift +++ b/ElementX/Sources/Screens/QRCodeLoginScreen/QRCodeLoginScreenModels.swift @@ -46,7 +46,7 @@ struct QRCodeLoginScreenViewState: BindableState { var state: QRCodeLoginState let mode: QRCodeLoginScreenMode /// Whether or not it is possible for the screen to start the manual sign in flow. This was added to avoid - /// having to handle server configuration when ``AppSettings.allowOtherAccountProviders`` is false. + /// having to handle server configuration when ``UserSettings.allowOtherAccountProviders`` is false. let canSignInManually: Bool let instructions = QRCodeLoginScreenInstructions() diff --git a/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift b/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift index 16113df22..be99da3d8 100644 --- a/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift +++ b/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift @@ -177,7 +177,7 @@ struct RoomDetailsEditScreen_Previews: PreviewProvider, TestablePreview { return RoomDetailsEditScreenViewModel(roomProxy: roomProxy, userSession: UserSessionMock(.init()), - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: .volatile()), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: .volatile()), userIndicatorController: UserIndicatorControllerMock()) } } diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenCoordinator.swift b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenCoordinator.swift index 5b289b858..b03307008 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenCoordinator.swift @@ -12,7 +12,7 @@ import SwiftUI struct RoomDetailsScreenCoordinatorParameters { let roomProxy: JoinedRoomProxyProtocol let userSession: UserSessionProtocol - let appSettings: AppSettings + let userSettings: UserSettings let appHooks: AppHooks let analyticsService: AnalyticsServiceProtocol let userIndicatorController: UserIndicatorControllerProtocol @@ -54,7 +54,7 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol { isSpace = parameters.roomProxy.infoPublisher.value.isSpace viewModel = RoomDetailsScreenViewModel(roomProxy: parameters.roomProxy, userSession: parameters.userSession, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, appHooks: parameters.appHooks, analyticsService: parameters.analyticsService, userIndicatorController: parameters.userIndicatorController, diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift index 5ade0c174..31b7e34cd 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift @@ -45,7 +45,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr init(roomProxy: JoinedRoomProxyProtocol, userSession: UserSessionProtocol, - appSettings: AppSettings, + userSettings: UserSettings, appHooks: AppHooks, analyticsService: AnalyticsServiceProtocol, userIndicatorController: UserIndicatorControllerProtocol, @@ -67,7 +67,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr topicSummary: topic?.unattributedStringByReplacingNewlinesWithSpaces(), joinedMembersCount: roomProxy.infoPublisher.value.joinedMembersCount, notificationSettingsState: .loading, - isNativeCallingEnabled: appSettings.nativeCallEnabled, + isNativeCallingEnabled: userSettings.nativeCallEnabled, bindings: .init()) super.init(initialViewState: appHooks.roomDetailsScreenHook.update(viewState), mediaProvider: userSession.mediaProvider) diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift b/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift index 0eabffbb1..8d723988f 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift @@ -441,7 +441,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { return .init(roomProxy: roomProxy, userSession: UserSessionMock(.init()), - appSettings: AppSettings.volatile(), + userSettings: UserSettings.volatile(), appHooks: AppHooks(), analyticsService: AnalyticsServiceMock(.init()), userIndicatorController: UserIndicatorControllerMock(), @@ -470,7 +470,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { return .init(roomProxy: roomProxy, userSession: UserSessionMock(.init()), - appSettings: AppSettings.volatile(), + userSettings: UserSettings.volatile(), appHooks: AppHooks(), analyticsService: AnalyticsServiceMock(.init()), userIndicatorController: UserIndicatorControllerMock(), @@ -509,7 +509,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { return .init(roomProxy: roomProxy, userSession: UserSessionMock(.init(clientProxy: clientProxyMock)), - appSettings: AppSettings.volatile(), + userSettings: UserSettings.volatile(), appHooks: AppHooks(), analyticsService: AnalyticsServiceMock(.init()), userIndicatorController: UserIndicatorControllerMock(), diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift index d61be3944..ae351b53a 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift @@ -65,7 +65,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool completionSuggestionService: CompletionSuggestionServiceProtocol, mediaProvider: MediaProviderProtocol, mentionDisplayHelper: MentionDisplayHelper, - appSettings: AppSettings, + userSettings: UserSettings, analyticsService: AnalyticsServiceProtocol, composerDraftService: ComposerDraftServiceProtocol) { self.initialText = initialText @@ -80,7 +80,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool super.init(initialViewState: ComposerToolbarViewState(wysiwygViewModel: wysiwygViewModel, isRoomEncrypted: roomProxy.infoPublisher.value.isEncrypted, - isLocationSharingEnabled: appSettings.mapTilerConfiguration.publisher.value.isEnabled, + isLocationSharingEnabled: userSettings.mapTilerConfiguration.publisher.value.isEnabled, bindings: .init()), mediaProvider: mediaProvider) @@ -852,7 +852,7 @@ extension ComposerToolbarViewModel { completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init(suggestions: suggestions)), mediaProvider: MediaProviderMock(.init()), mentionDisplayHelper: ComposerMentionDisplayHelper.mock, - appSettings: .volatile(), + userSettings: .volatile(), analyticsService: AnalyticsServiceMock(.init()), composerDraftService: ComposerDraftServiceMock(.init())) viewModel.state.bindings.composerFocused = focused diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift index f981971a1..ae9172ea7 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift @@ -81,14 +81,14 @@ struct RoomAttachmentPicker_Previews: PreviewProvider, TestablePreview { static let viewModel = makeViewModel() static func makeViewModel() -> ComposerToolbarViewModel { - let appSettings = AppSettings.volatile() + let userSettings = UserSettings.volatile() return ComposerToolbarViewModel(roomProxy: JoinedRoomProxyMock(.init()), wysiwygViewModel: WysiwygComposerViewModel(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), mediaProvider: MediaProviderMock(.init()), mentionDisplayHelper: ComposerMentionDisplayHelper.mock, - appSettings: appSettings, + userSettings: userSettings, analyticsService: AnalyticsServiceMock(.init()), composerDraftService: ComposerDraftServiceMock(.init())) } diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift index 8ce0ad64d..f6285419e 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift @@ -24,7 +24,6 @@ struct RoomScreenCoordinatorParameters { let completionSuggestionService: CompletionSuggestionServiceProtocol let ongoingCallRoomIDPublisher: CurrentValuePublisher let appMediator: AppMediatorProtocol - let appSettings: AppSettings let appHooks: AppHooks let analytics: AnalyticsServiceProtocol let composerDraftService: ComposerDraftServiceProtocol @@ -57,7 +56,7 @@ final class RoomScreenCoordinator: CoordinatorProtocol { private var roomViewModel: RoomScreenViewModelProtocol private var timelineViewModel: TimelineViewModelProtocol private var composerViewModel: ComposerToolbarViewModelProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private var cancellables = Set() @@ -67,7 +66,7 @@ final class RoomScreenCoordinator: CoordinatorProtocol { } init(parameters: RoomScreenCoordinatorParameters) { - appSettings = parameters.appSettings + userSettings = parameters.userSession.userSettings var selectedPinnedEventID: String? if let focussedEvent = parameters.focussedEvent { @@ -78,7 +77,6 @@ final class RoomScreenCoordinator: CoordinatorProtocol { roomProxy: parameters.roomProxy, initialSelectedPinnedEventID: selectedPinnedEventID, ongoingCallRoomIDPublisher: parameters.ongoingCallRoomIDPublisher, - appSettings: parameters.appSettings, appHooks: parameters.appHooks, analyticsService: parameters.analytics, userIndicatorController: parameters.userIndicatorController) @@ -90,7 +88,6 @@ final class RoomScreenCoordinator: CoordinatorProtocol { mediaPlayerProvider: parameters.mediaPlayerProvider, userIndicatorController: parameters.userIndicatorController, appMediator: parameters.appMediator, - appSettings: parameters.appSettings, analyticsService: parameters.analytics, emojiProvider: parameters.emojiProvider, linkMetadataProvider: parameters.linkMetadataProvider, @@ -106,7 +103,7 @@ final class RoomScreenCoordinator: CoordinatorProtocol { completionSuggestionService: parameters.completionSuggestionService, mediaProvider: parameters.userSession.mediaProvider, mentionDisplayHelper: ComposerMentionDisplayHelper(timelineContext: timelineViewModel.context), - appSettings: parameters.appSettings, + userSettings: parameters.userSession.userSettings, analyticsService: parameters.analytics, composerDraftService: parameters.composerDraftService) self.composerViewModel = composerViewModel @@ -125,13 +122,13 @@ final class RoomScreenCoordinator: CoordinatorProtocol { case .displayReportContent(let itemID, let senderID): actionsSubject.send(.presentReportContent(itemID: itemID, senderID: senderID)) case .displayCameraPicker: - actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .camera, selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)), + actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .camera, selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)), caption: composerViewModel.context.plainComposerText)) case .displayMediaPicker: - actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .photoLibrary, selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)), + actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .photoLibrary, selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)), caption: composerViewModel.context.plainComposerText)) case .displayDocumentPicker: - actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .documents(), selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)), + actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .documents(), selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)), caption: composerViewModel.context.plainComposerText)) case .displayMediaPreview(let mediaPreviewViewModel): roomViewModel.displayMediaPreview(mediaPreviewViewModel) diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift index 21db6f7ac..134cff3ac 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift @@ -17,7 +17,7 @@ typealias RoomScreenViewModelType = StateStoreViewModel, - appSettings: AppSettings, appHooks: AppHooks, analyticsService: AnalyticsServiceProtocol, userIndicatorController: UserIndicatorControllerProtocol) { clientProxy = userSession.clientProxy self.roomProxy = roomProxy - self.appSettings = appSettings + userSettings = userSession.userSettings self.analyticsService = analyticsService self.userIndicatorController = userIndicatorController @@ -69,7 +68,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol let viewState = RoomScreenViewState(roomTitle: roomProxy.infoPublisher.value.displayNameOrID, roomAvatar: roomProxy.infoPublisher.value.avatar, - isNativeCallingEnabled: appSettings.nativeCallEnabled, + isNativeCallingEnabled: userSettings.nativeCallEnabled, hasOngoingCall: roomProxy.infoPublisher.value.hasRoomCall, isDM: roomProxy.infoPublisher.value.isDM, hasSuccessor: roomProxy.infoPublisher.value.successor != nil, @@ -128,7 +127,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol Task { // When navigating away from the room, we need to mark the room as both read // and fully read for Synapse to clear this room from the app's badge count. - _ = await roomProxy.markAsRead(receiptType: appSettings.sharePresence ? .read : .readPrivate) + _ = await roomProxy.markAsRead(receiptType: userSettings.sharePresence ? .read : .readPrivate) _ = await roomProxy.markAsRead(receiptType: .fullyRead) } // Work around QLPreviewController dismissal issues, see the InteractiveQuickLookModifier. @@ -167,11 +166,11 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol // MARK: - Private private func setupSubscriptions(ongoingCallRoomIDPublisher: CurrentValuePublisher) { - appSettings.threadsEnabledPublisher + userSettings.threadsEnabledPublisher .weakAssign(to: \.state.roomThreadListEnabled, on: self) .store(in: &cancellables) - appSettings.liveLocationSharingSessionsByRoomIDPublisher + userSettings.liveLocationSharingSessionsByRoomIDPublisher .receive(on: DispatchQueue.main) .sink { [weak self] sessionsByRoomID in guard let self else { return } @@ -265,10 +264,10 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol if let member = identityVerificationViolations.values.first { state.footerDetails = .verificationViolation(member: member, - learnMoreURL: appSettings.identityPinningViolationDetailsURL) + learnMoreURL: userSettings.identityPinningViolationDetailsURL) } else if let member = identityPinningViolations.values.first { state.footerDetails = .pinViolation(member: member, - learnMoreURL: appSettings.identityPinningViolationDetailsURL) + learnMoreURL: userSettings.identityPinningViolationDetailsURL) } else { state.footerDetails = nil } @@ -429,7 +428,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol Task { switch await roomProxy.loadOrFetchEventDetails(for: eventID) { case .success(let event): - if appSettings.threadsEnabled, + if userSettings.threadsEnabled, let threadRootEventID = event.threadRootEventId() { actionsSubject.send(.focusEvent(eventID: threadRootEventID)) actionsSubject.send(.displayThread(threadRootEventID: threadRootEventID, focussedEventID: eventID)) @@ -466,7 +465,6 @@ extension RoomScreenViewModel { roomProxy: roomProxyMock, initialSelectedPinnedEventID: nil, ongoingCallRoomIDPublisher: .init(.init(nil)), - appSettings: .volatile(), appHooks: appHooks, analyticsService: AnalyticsServiceMock(.init()), userIndicatorController: UserIndicatorControllerMock()) diff --git a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift index de38691bf..731521f4a 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift @@ -395,19 +395,19 @@ struct RoomScreen_Previews: PreviewProvider, TestablePreview { powerLevelsConfiguration: .init(canUserSendMessage: canSendMessage))) let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock) - let appSettings = AppSettings.volatile() - appSettings.messageMultiSelectEnabled = isSelecting + let userSettings = UserSettings.volatile() + userSettings.messageMultiSelectEnabled = isSelecting + let userSession = UserSessionMock(.init(userSettings: userSettings)) let timelineController = TimelineControllerMock(.init()) let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock, timelineController: timelineController, - userSession: UserSessionMock(.init()), + userSession: userSession, mediaPlayerProvider: MediaPlayerProviderMock(), userIndicatorController: UserIndicatorControllerMock(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: userSettings), linkMetadataProvider: LinkMetadataProvider(), timelineControllerFactory: TimelineControllerFactoryMock(.init())) diff --git a/ElementX/Sources/Screens/SearchScreen/SearchScreenCoordinator.swift b/ElementX/Sources/Screens/SearchScreen/SearchScreenCoordinator.swift index 50bdb5086..d8ff736d4 100644 --- a/ElementX/Sources/Screens/SearchScreen/SearchScreenCoordinator.swift +++ b/ElementX/Sources/Screens/SearchScreen/SearchScreenCoordinator.swift @@ -13,7 +13,7 @@ struct SearchScreenCoordinatorParameters { let clientProxy: ClientProxyProtocol let mediaProvider: MediaProviderProtocol let userIndicatorController: UserIndicatorControllerProtocol - let appSettings: AppSettings + let userSettings: UserSettings } enum SearchScreenCoordinatorAction { @@ -36,7 +36,7 @@ final class SearchScreenCoordinator: CoordinatorProtocol { clientProxy: parameters.clientProxy, mediaProvider: parameters.mediaProvider, userIndicatorController: parameters.userIndicatorController, - appSettings: parameters.appSettings) + userSettings: parameters.userSettings) } func start() { diff --git a/ElementX/Sources/Screens/SearchScreen/SearchScreenViewModel.swift b/ElementX/Sources/Screens/SearchScreen/SearchScreenViewModel.swift index 2da0fe720..7a3dd15d2 100644 --- a/ElementX/Sources/Screens/SearchScreen/SearchScreenViewModel.swift +++ b/ElementX/Sources/Screens/SearchScreen/SearchScreenViewModel.swift @@ -19,7 +19,7 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro private let clientProxy: ClientProxyProtocol private let searchService: SearchServiceProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private var searchQueryObservationTask: Task? private var searchModeObservationTask: Task? private var loadingObservationTask: Task? @@ -36,14 +36,14 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro clientProxy: ClientProxyProtocol, mediaProvider: MediaProviderProtocol, userIndicatorController: UserIndicatorControllerProtocol, - appSettings: AppSettings, + userSettings: UserSettings, initialSearchQuery: String = "", initialSearchMode: SearchScreenMode = .rooms) { self.roomSummaryProvider = roomSummaryProvider self.clientProxy = clientProxy searchService = clientProxy.searchService self.userIndicatorController = userIndicatorController - self.appSettings = appSettings + self.userSettings = userSettings super.init(initialViewState: SearchScreenViewState(bindings: .init(searchQuery: initialSearchQuery, searchMode: initialSearchMode)), mediaProvider: mediaProvider) @@ -73,7 +73,7 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro .store(in: &cancellables) // The room list is empty on a cold start, so the room breadcrumbs are re-resolved as it loads. - appSettings.searchBreadcrumbsPublisher + userSettings.searchBreadcrumbsPublisher .combineLatest(clientProxy.staticRoomSummaryProvider.roomListPublisher) .receive(on: DispatchQueue.main) .sink { [weak self] storedBreadcrumbs, _ in @@ -118,7 +118,7 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro } updateRooms(with: roomSummaryProvider.roomListPublisher.value) - state.breadcrumbs = makeBreadcrumbs(from: appSettings.searchBreadcrumbs) + state.breadcrumbs = makeBreadcrumbs(from: userSettings.searchBreadcrumbs) } isolated deinit { @@ -215,13 +215,13 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro let searchQuery = state.bindings.searchQuery let newBreadcrumbs: [SearchBreadcrumb] = searchQuery.isEmpty ? [.room(roomID: roomID)] : [.query(searchQuery), .room(roomID: roomID)] - var breadcrumbs = appSettings.searchBreadcrumbs + var breadcrumbs = userSettings.searchBreadcrumbs for breadcrumb in newBreadcrumbs { breadcrumbs.removeAll { $0 == breadcrumb } breadcrumbs.insert(breadcrumb, at: 0) } - appSettings.searchBreadcrumbs = Array(breadcrumbs.prefix(Self.maximumBreadcrumbCount)) + userSettings.searchBreadcrumbs = Array(breadcrumbs.prefix(Self.maximumBreadcrumbCount)) } private func setActiveTabLoading(_ isLoading: Bool) { diff --git a/ElementX/Sources/Screens/SearchScreen/View/SearchScreen.swift b/ElementX/Sources/Screens/SearchScreen/View/SearchScreen.swift index 7f5b98bc9..523bdb446 100644 --- a/ElementX/Sources/Screens/SearchScreen/View/SearchScreen.swift +++ b/ElementX/Sources/Screens/SearchScreen/View/SearchScreen.swift @@ -577,31 +577,31 @@ struct SearchScreen_Previews: PreviewProvider, TestablePreview { clientProxy: makeClientProxy(), mediaProvider: MediaProviderMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings.volatile()) + userSettings: UserSettings.volatile()) static let noResultsViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))), clientProxy: makeClientProxy(), mediaProvider: MediaProviderMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings.volatile(), + userSettings: UserSettings.volatile(), initialSearchQuery: "John Doe") static let roomsViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))), clientProxy: makeClientProxy(), mediaProvider: MediaProviderMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings.volatile(), + userSettings: UserSettings.volatile(), initialSearchQuery: "Foundation") static let messagesViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))), clientProxy: makeClientProxy(searchService: makeSearchService(results: .mockResults)), mediaProvider: MediaProviderMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings.volatile(), + userSettings: UserSettings.volatile(), initialSearchQuery: "Foundation", initialSearchMode: .messages) static let loadingMessagesViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))), clientProxy: makeClientProxy(searchService: makeSearchService(paginationState: .loading)), mediaProvider: MediaProviderMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings.volatile(), + userSettings: UserSettings.volatile(), initialSearchQuery: "Foundation", initialSearchMode: .messages) @@ -609,11 +609,11 @@ struct SearchScreen_Previews: PreviewProvider, TestablePreview { clientProxy: makeClientProxy(), mediaProvider: MediaProviderMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: makeAppSettings(breadcrumbs: [.room(roomID: "!room1:matrix.org"), - .query("Bob"), - .room(roomID: "!room5:matrix.org"), - .query("Element HR"), - .query("Alice")])) + userSettings: makeUserSettings(breadcrumbs: [.room(roomID: "!room1:matrix.org"), + .query("Bob"), + .room(roomID: "!room5:matrix.org"), + .query("Element HR"), + .query("Alice")])) static var previews: some View { ElementNavigationStack { @@ -655,10 +655,10 @@ struct SearchScreen_Previews: PreviewProvider, TestablePreview { return mock } - private static func makeAppSettings(breadcrumbs: [SearchBreadcrumb]) -> AppSettings { - let appSettings = AppSettings.volatile() - appSettings.searchBreadcrumbs = breadcrumbs - return appSettings + private static func makeUserSettings(breadcrumbs: [SearchBreadcrumb]) -> UserSettings { + let userSettings = UserSettings.volatile() + userSettings.searchBreadcrumbs = breadcrumbs + return userSettings } private static func makeClientProxy(searchService: SearchServiceProxyMock = makeSearchService()) -> ClientProxyMock { diff --git a/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenCoordinator.swift b/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenCoordinator.swift index 7dc06fc24..9723d5cf5 100644 --- a/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenCoordinator.swift +++ b/ElementX/Sources/Screens/SecureBackup/SecureBackupScreen/SecureBackupScreenCoordinator.swift @@ -10,7 +10,7 @@ import Combine import SwiftUI struct SecureBackupScreenCoordinatorParameters { - let appSettings: AppSettings + let userSettings: UserSettings let clientProxy: ClientProxyProtocol let userIndicatorController: UserIndicatorControllerProtocol } @@ -33,7 +33,7 @@ final class SecureBackupScreenCoordinator: CoordinatorProtocol { init(parameters: SecureBackupScreenCoordinatorParameters) { viewModel = SecureBackupScreenViewModel(secureBackupController: parameters.clientProxy.secureBackupController, userIndicatorController: parameters.userIndicatorController, - chatBackupDetailsURL: parameters.appSettings.chatBackupDetailsURL) + chatBackupDetailsURL: parameters.userSettings.chatBackupDetailsURL) } func start() { diff --git a/ElementX/Sources/Screens/SecurityAndPrivacyScreen/SecurityAndPrivacyScreenCoordinator.swift b/ElementX/Sources/Screens/SecurityAndPrivacyScreen/SecurityAndPrivacyScreenCoordinator.swift index 22b886fbc..cae3edaf9 100644 --- a/ElementX/Sources/Screens/SecurityAndPrivacyScreen/SecurityAndPrivacyScreenCoordinator.swift +++ b/ElementX/Sources/Screens/SecurityAndPrivacyScreen/SecurityAndPrivacyScreenCoordinator.swift @@ -13,7 +13,7 @@ struct SecurityAndPrivacyScreenCoordinatorParameters { let roomProxy: JoinedRoomProxyProtocol let clientProxy: ClientProxyProtocol let userIndicatorController: UserIndicatorControllerProtocol - let appSetting: AppSettings + let appSetting: UserSettings } enum SecurityAndPrivacyScreenCoordinatorAction { @@ -36,7 +36,7 @@ final class SecurityAndPrivacyScreenCoordinator: CoordinatorProtocol { viewModel = SecurityAndPrivacyScreenViewModel(roomProxy: parameters.roomProxy, clientProxy: parameters.clientProxy, userIndicatorController: parameters.userIndicatorController, - appSettings: parameters.appSetting) + userSettings: parameters.appSetting) } func start() { diff --git a/ElementX/Sources/Screens/SecurityAndPrivacyScreen/SecurityAndPrivacyScreenViewModel.swift b/ElementX/Sources/Screens/SecurityAndPrivacyScreen/SecurityAndPrivacyScreenViewModel.swift index d33d80d03..b8cada92a 100644 --- a/ElementX/Sources/Screens/SecurityAndPrivacyScreen/SecurityAndPrivacyScreenViewModel.swift +++ b/ElementX/Sources/Screens/SecurityAndPrivacyScreen/SecurityAndPrivacyScreenViewModel.swift @@ -16,7 +16,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType, private let roomProxy: JoinedRoomProxyProtocol private let clientProxy: ClientProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let actionsSubject: PassthroughSubject = .init() var actionsPublisher: AnyPublisher { @@ -26,18 +26,18 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType, init(roomProxy: JoinedRoomProxyProtocol, clientProxy: ClientProxyProtocol, userIndicatorController: UserIndicatorControllerProtocol, - appSettings: AppSettings) { + userSettings: UserSettings) { self.roomProxy = roomProxy self.clientProxy = clientProxy self.userIndicatorController = userIndicatorController - self.appSettings = appSettings + self.userSettings = userSettings super.init(initialViewState: SecurityAndPrivacyScreenViewState(accessType: roomProxy.infoPublisher.value.joinRule.toSecurityAndPrivacyRoomAccessType, isEncryptionEnabled: roomProxy.infoPublisher.value.isEncrypted, historyVisibility: roomProxy.infoPublisher.value.historyVisibility.toSecurityAndPrivacyHistoryVisibility, isSpace: roomProxy.infoPublisher.value.isSpace, - isKnockingEnabled: appSettings.knockingEnabled, - historySharingDetailsURL: appSettings.historySharingDetailsURL)) + isKnockingEnabled: userSettings.knockingEnabled, + historySharingDetailsURL: userSettings.historySharingDetailsURL)) if let powerLevels = roomProxy.infoPublisher.value.powerLevels { setupPermissions(powerLevels: powerLevels) @@ -151,7 +151,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType, .weakAssign(to: \.state.isSpace, on: self) .store(in: &cancellables) - appSettings.knockingEnabledPublisher + userSettings.knockingEnabledPublisher .weakAssign(to: \.state.isKnockingEnabled, on: self) .store(in: &cancellables) } @@ -160,7 +160,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType, state.canEditAddress = powerLevels.canOwnUser(sendStateEvent: .roomCanonicalAlias) state.canEditJoinRule = powerLevels.canOwnUser(sendStateEvent: .roomJoinRules) state.canEditHistoryVisibility = powerLevels.canOwnUser(sendStateEvent: .roomHistoryVisibility) - state.canEnableEncryption = powerLevels.canOwnUser(sendStateEvent: .roomEncryption) && !appSettings.forceDisableE2EE.publisher.value + state.canEnableEncryption = powerLevels.canOwnUser(sendStateEvent: .roomEncryption) && !userSettings.forceDisableE2EE.publisher.value } private func setupRoomDirectoryVisibility() { diff --git a/ElementX/Sources/Screens/SecurityAndPrivacyScreen/View/SecurityAndPrivacyScreen.swift b/ElementX/Sources/Screens/SecurityAndPrivacyScreen/View/SecurityAndPrivacyScreen.swift index f8df952e6..c7fffd1c7 100644 --- a/ElementX/Sources/Screens/SecurityAndPrivacyScreen/View/SecurityAndPrivacyScreen.swift +++ b/ElementX/Sources/Screens/SecurityAndPrivacyScreen/View/SecurityAndPrivacyScreen.swift @@ -233,7 +233,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { joinRule: .invite)), clientProxy: ClientProxyMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: .volatile()) + userSettings: .volatile()) static let publicViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false, canonicalAlias: "#room:matrix.org", @@ -242,17 +242,17 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { isVisibleInPublicDirectory: true)), clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), userIndicatorController: UserIndicatorControllerMock(), - appSettings: .volatile()) + userSettings: .volatile()) static let publicNoAddressViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false, members: .allMembersAsCreator, joinRule: .public)), clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), userIndicatorController: UserIndicatorControllerMock(), - appSettings: .volatile()) + userSettings: .volatile()) static let singleSpaceMembersViewModel = { - let appSettings = AppSettings.volatile() + let userSettings = UserSettings.volatile() let space = [SpaceServiceRoom].mockSingleRoom[0] @@ -264,11 +264,11 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org", spaceServiceConfiguration: .init(joinedParentSpaces: [space]))), userIndicatorController: UserIndicatorControllerMock(), - appSettings: appSettings) + userSettings: userSettings) }() static let multipleSpacesMembersViewModel = { - let appSettings = AppSettings.volatile() + let userSettings = UserSettings.volatile() let spaces = [SpaceServiceRoom].mockJoinedSpaces @@ -280,12 +280,12 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org", spaceServiceConfiguration: .init(joinedParentSpaces: spaces))), userIndicatorController: UserIndicatorControllerMock(), - appSettings: appSettings) + userSettings: userSettings) }() static let askToJoinViewModel = { - let appSettings = AppSettings.volatile() - appSettings.knockingEnabled = true + let userSettings = UserSettings.volatile() + userSettings.knockingEnabled = true return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false, canonicalAlias: "#room:matrix.org", @@ -294,12 +294,12 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { isVisibleInPublicDirectory: true)), clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), userIndicatorController: UserIndicatorControllerMock(), - appSettings: appSettings) + userSettings: userSettings) }() static let singleAskToJoinSpaceMembersViewModel = { - let appSettings = AppSettings.volatile() - appSettings.knockingEnabled = true + let userSettings = UserSettings.volatile() + userSettings.knockingEnabled = true let space = [SpaceServiceRoom].mockSingleRoom[0] @@ -311,12 +311,12 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org", spaceServiceConfiguration: .init(joinedParentSpaces: [space]))), userIndicatorController: UserIndicatorControllerMock(), - appSettings: appSettings) + userSettings: userSettings) }() static let multipleAskToJoinSpacesMembersViewModel = { - let appSettings = AppSettings.volatile() - appSettings.knockingEnabled = true + let userSettings = UserSettings.volatile() + userSettings.knockingEnabled = true let spaces = [SpaceServiceRoom].mockJoinedSpaces @@ -328,7 +328,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org", spaceServiceConfiguration: .init(joinedParentSpaces: spaces))), userIndicatorController: UserIndicatorControllerMock(), - appSettings: appSettings) + userSettings: userSettings) }() static let publicSpaceViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isSpace: true, @@ -339,7 +339,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { isVisibleInPublicDirectory: true)), clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), userIndicatorController: UserIndicatorControllerMock(), - appSettings: .volatile()) + userSettings: .volatile()) static var previews: some View { ElementNavigationStack { diff --git a/ElementX/Sources/Screens/Settings/AccountSettings/OAuthAccountSettingsPresenter.swift b/ElementX/Sources/Screens/Settings/AccountSettings/OAuthAccountSettingsPresenter.swift index be0cd66cf..d872835ae 100644 --- a/ElementX/Sources/Screens/Settings/AccountSettings/OAuthAccountSettingsPresenter.swift +++ b/ElementX/Sources/Screens/Settings/AccountSettings/OAuthAccountSettingsPresenter.swift @@ -27,11 +27,11 @@ class OAuthAccountSettingsPresenter: NSObject { init(accountURL: URL, presentationAnchor: UIWindow, appMediator: AppMediatorProtocol, - appSettings: AppSettings, + userSettings: UserSettings, appHooks: AppHooks, continuation: Continuation? = nil) { self.accountURL = accountURL - redirectURL = appSettings.oAuthRedirectURL + redirectURL = userSettings.oAuthRedirectURL self.presentationAnchor = presentationAnchor self.appMediator = appMediator self.appHooks = appHooks diff --git a/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/AdvancedSettingsScreenCoordinator.swift b/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/AdvancedSettingsScreenCoordinator.swift index 0f13fe139..0e6a702b3 100644 --- a/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/AdvancedSettingsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/AdvancedSettingsScreenCoordinator.swift @@ -10,7 +10,7 @@ import Combine import SwiftUI struct AdvancedSettingsScreenCoordinatorParameters { - let appSettings: AppSettings + let userSettings: UserSettings let analytics: AnalyticsServiceProtocol let clientProxy: ClientProxyProtocol let userIndicatorController: UserIndicatorControllerProtocol @@ -20,7 +20,7 @@ final class AdvancedSettingsScreenCoordinator: CoordinatorProtocol { private var viewModel: AdvancedSettingsScreenViewModelProtocol init(parameters: AdvancedSettingsScreenCoordinatorParameters) { - viewModel = AdvancedSettingsScreenViewModel(advancedSettings: parameters.appSettings, + viewModel = AdvancedSettingsScreenViewModel(advancedSettings: parameters.userSettings.app, analytics: parameters.analytics, clientProxy: parameters.clientProxy, userIndicatorController: parameters.userIndicatorController) diff --git a/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/AdvancedSettingsScreenViewModel.swift b/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/AdvancedSettingsScreenViewModel.swift index 5dce5c05b..c59085694 100644 --- a/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/AdvancedSettingsScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/AdvancedSettingsScreenViewModel.swift @@ -48,7 +48,7 @@ class AdvancedSettingsScreenViewModel: AdvancedSettingsScreenViewModelType, Adva override func process(viewAction: AdvancedSettingsScreenViewAction) { switch viewAction { case .optimizeMediaUploadsChanged: - // Note: Using a view action here as sinking the AppSettings publisher tracks the initial value. + // Note: Using a view action here as sinking the UserSettings publisher tracks the initial value. analytics.trackInteraction(name: state.bindings.optimizeMediaUploads ? .MobileSettingsOptimizeMediaUploadsEnabled : .MobileSettingsOptimizeMediaUploadsDisabled) case let .updateHideInviteAvatars(value): hideInviteAvatarsTask = Task { [weak self] in await self?.updateHideInviteAvatars(value) } diff --git a/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/View/AdvancedSettingsScreen.swift b/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/View/AdvancedSettingsScreen.swift index 8b47f2da8..de2d8b5d4 100644 --- a/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/View/AdvancedSettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/View/AdvancedSettingsScreen.swift @@ -160,13 +160,10 @@ private extension AppAppearance { // MARK: - Previews struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview { - static let viewModel = { - let appSettings = AppSettings.volatile() - return AdvancedSettingsScreenViewModel(advancedSettings: appSettings, - analytics: AnalyticsServiceMock(.init()), - clientProxy: ClientProxyMock(.init()), - userIndicatorController: UserIndicatorControllerMock()) - }() + static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: AppSettings.volatile(), + analytics: AnalyticsServiceMock(.init()), + clientProxy: ClientProxyMock(.init()), + userIndicatorController: UserIndicatorControllerMock()) static var previews: some View { ElementNavigationStack { diff --git a/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/AnalyticsSettingsScreenCoordinator.swift b/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/AnalyticsSettingsScreenCoordinator.swift index 559fdb9c6..1dc0dd1b8 100644 --- a/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/AnalyticsSettingsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/AnalyticsSettingsScreenCoordinator.swift @@ -10,7 +10,7 @@ import Combine import SwiftUI struct AnalyticsSettingsScreenCoordinatorParameters { - let appSettings: AppSettings + let userSettings: UserSettings let analytics: AnalyticsServiceProtocol } @@ -18,7 +18,7 @@ final class AnalyticsSettingsScreenCoordinator: CoordinatorProtocol { private let viewModel: AnalyticsSettingsScreenViewModel init(parameters: AnalyticsSettingsScreenCoordinatorParameters) { - viewModel = AnalyticsSettingsScreenViewModel(appSettings: parameters.appSettings, + viewModel = AnalyticsSettingsScreenViewModel(userSettings: parameters.userSettings, analytics: parameters.analytics) } diff --git a/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/AnalyticsSettingsScreenViewModel.swift b/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/AnalyticsSettingsScreenViewModel.swift index 3a04c855b..bf25f6d94 100644 --- a/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/AnalyticsSettingsScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/AnalyticsSettingsScreenViewModel.swift @@ -14,16 +14,16 @@ typealias AnalyticsSettingsScreenViewModelType = StateStoreViewModelV2 AnyView { diff --git a/ElementX/Sources/Screens/Settings/LegalInformationScreen/LegalInformationScreenViewModel.swift b/ElementX/Sources/Screens/Settings/LegalInformationScreen/LegalInformationScreenViewModel.swift index 67b0b2044..c959e65f8 100644 --- a/ElementX/Sources/Screens/Settings/LegalInformationScreen/LegalInformationScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/LegalInformationScreen/LegalInformationScreenViewModel.swift @@ -12,9 +12,9 @@ import SwiftUI typealias LegalInformationScreenViewModelType = StateStoreViewModelV2 class LegalInformationScreenViewModel: LegalInformationScreenViewModelType, LegalInformationScreenViewModelProtocol { - init(appSettings: AppSettings) { - super.init(initialViewState: LegalInformationScreenViewState(copyrightURL: appSettings.copyrightURL, - acceptableUseURL: appSettings.acceptableUseURL, - privacyURL: appSettings.privacyURL)) + init(userSettings: UserSettings) { + super.init(initialViewState: LegalInformationScreenViewState(copyrightURL: userSettings.copyrightURL, + acceptableUseURL: userSettings.acceptableUseURL, + privacyURL: userSettings.privacyURL)) } } diff --git a/ElementX/Sources/Screens/Settings/LegalInformationScreen/View/LegalInformationScreen.swift b/ElementX/Sources/Screens/Settings/LegalInformationScreen/View/LegalInformationScreen.swift index 199b9b4a1..ac875d059 100644 --- a/ElementX/Sources/Screens/Settings/LegalInformationScreen/View/LegalInformationScreen.swift +++ b/ElementX/Sources/Screens/Settings/LegalInformationScreen/View/LegalInformationScreen.swift @@ -33,7 +33,7 @@ struct LegalInformationScreen: View { // MARK: - Previews struct LegalInformationScreen_Previews: PreviewProvider, TestablePreview { - static let viewModel = LegalInformationScreenViewModel(appSettings: .volatile()) + static let viewModel = LegalInformationScreenViewModel(userSettings: .volatile()) static var previews: some View { LegalInformationScreen(context: viewModel.context) } diff --git a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenCoordinator.swift b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenCoordinator.swift index a01a20495..fdcf43959 100644 --- a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenCoordinator.swift @@ -15,7 +15,7 @@ struct NotificationSettingsScreenCoordinatorParameters { let userNotificationCenter: UserNotificationCenterProtocol let userIndicatorController: UserIndicatorControllerProtocol let isModallyPresented: Bool - let appSettings: AppSettings + let userSettings: UserSettings } enum NotificationSettingsScreenCoordinatorAction { @@ -39,9 +39,9 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol { init(parameters: NotificationSettingsScreenCoordinatorParameters) { self.parameters = parameters - viewModel = NotificationSettingsScreenViewModel(appSettings: parameters.appSettings, + viewModel = NotificationSettingsScreenViewModel(userSettings: parameters.userSettings, userNotificationCenter: parameters.userNotificationCenter, - notificationToneManager: NotificationToneManager(appSettings: parameters.appSettings), + notificationToneManager: NotificationToneManager(userSettings: parameters.userSettings), notificationSettingsProxy: parameters.userSession.clientProxy.notificationSettings, userIndicatorController: parameters.userIndicatorController, isModallyPresented: parameters.isModallyPresented) diff --git a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenViewModel.swift b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenViewModel.swift index 8482f6a52..bb638d263 100644 --- a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/NotificationSettingsScreenViewModel.swift @@ -13,7 +13,7 @@ typealias NotificationSettingsScreenViewModelType = StateStoreViewModelV2 = .init() - private let appSettings: AppSettings + private let userSettings: UserSettings private let userNotificationCenter: UserNotificationCenterProtocol private let notificationSettingsProxy: NotificationSettingsProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol @@ -25,34 +25,34 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy actionsSubject.eraseToAnyPublisher() } - init(appSettings: AppSettings, + init(userSettings: UserSettings, userNotificationCenter: UserNotificationCenterProtocol, notificationToneManager: NotificationToneManagerProtocol, notificationSettingsProxy: NotificationSettingsProxyProtocol, userIndicatorController: UserIndicatorControllerProtocol, isModallyPresented: Bool) { - self.appSettings = appSettings + self.userSettings = userSettings self.userNotificationCenter = userNotificationCenter self.notificationSettingsProxy = notificationSettingsProxy self.userIndicatorController = userIndicatorController notificationTonePreviewer = AudioPlayer() self.notificationToneManager = notificationToneManager - let bindings = NotificationSettingsScreenViewStateBindings(enableNotifications: appSettings.enableNotifications, - showAllRoomListActivity: appSettings.showAllRoomListActivity) + let bindings = NotificationSettingsScreenViewStateBindings(enableNotifications: userSettings.enableNotifications, + showAllRoomListActivity: userSettings.showAllRoomListActivity) super.init(initialViewState: NotificationSettingsScreenViewState(bindings: bindings, isModallyPresented: isModallyPresented, - selectedAlertTone: appSettings.selectedNotificationTone ?? NotificationToneManager.defaultElementXMessageTone, + selectedAlertTone: userSettings.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 AppSettings. - appSettings.enableNotificationsPublisher + // Listen for changes to UserSettings. + userSettings.enableNotificationsPublisher .weakAssign(to: \.state.bindings.enableNotifications, on: self) .store(in: &cancellables) - appSettings.selectedNotificationTonePublisher + userSettings.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: - appSettings.showAllRoomListActivity = state.bindings.showAllRoomListActivity + userSettings.showAllRoomListActivity = state.bindings.showAllRoomListActivity case .close: actionsSubject.send(.close) case .fixConfigurationMismatchTapped: @@ -127,7 +127,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy } func toggleNotifications() { - appSettings.enableNotifications.toggle() + userSettings.enableNotifications.toggle() } private func setupDidBecomeActiveSubscription() { @@ -302,7 +302,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy try notificationToneManager.deleteCustomTone(tone) if tone == state.selectedAlertTone { - appSettings.selectedNotificationTone = nil + userSettings.selectedNotificationTone = nil } } catch { MXLog.error("Error deleting alert tone \(tone.label): \(error)") diff --git a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/View/NotificationSettingsScreen.swift b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/View/NotificationSettingsScreen.swift index b3d3c7160..07edf1f2c 100644 --- a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/View/NotificationSettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/View/NotificationSettingsScreen.swift @@ -261,7 +261,7 @@ struct NotificationSettingsScreen: View { @available(iOS 26.0, *) struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview { static let viewModel: NotificationSettingsScreenViewModel = { - let appSettings = AppSettings.volatile() + let userSettings = UserSettings.volatile() let notificationCenter = UserNotificationCenterMock() notificationCenter.authorizationStatusReturnValue = .notDetermined let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init()) @@ -278,7 +278,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview { let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe")))) - var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings, + var viewModel = NotificationSettingsScreenViewModel(userSettings: userSettings, userNotificationCenter: notificationCenter, notificationToneManager: NotificationToneManagerMock(.init()), notificationSettingsProxy: notificationSettingsProxy, @@ -289,7 +289,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview { }() static let viewModelConfigurationMismatch: NotificationSettingsScreenViewModel = { - let appSettings = AppSettings.volatile() + let userSettings = UserSettings.volatile() let notificationCenter = UserNotificationCenterMock() notificationCenter.authorizationStatusReturnValue = .notDetermined let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init()) @@ -308,7 +308,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview { let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe")))) - var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings, + var viewModel = NotificationSettingsScreenViewModel(userSettings: userSettings, userNotificationCenter: notificationCenter, notificationToneManager: NotificationToneManagerMock(.init()), notificationSettingsProxy: notificationSettingsProxy, diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenCoordinator.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenCoordinator.swift index 0eb5b8f76..b21423ff9 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenCoordinator.swift @@ -11,7 +11,7 @@ import SwiftUI struct SettingsScreenCoordinatorParameters { let userSession: UserSessionProtocol - let appSettings: AppSettings + let userSettings: UserSettings let isBugReportServiceEnabled: Bool let isInSecondaryWindow: Bool let userIndicatorController: UserIndicatorControllerProtocol @@ -51,7 +51,7 @@ final class SettingsScreenCoordinator: CoordinatorProtocol { init(parameters: SettingsScreenCoordinatorParameters) { viewModel = SettingsScreenViewModel(userSession: parameters.userSession, - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, isBugReportServiceEnabled: parameters.isBugReportServiceEnabled, isInSecondaryWindow: parameters.isInSecondaryWindow, userIndicatorController: parameters.userIndicatorController) diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift index 8701e6a27..c0c4d4b12 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift @@ -12,7 +12,7 @@ import SwiftUI typealias SettingsScreenViewModelType = StateStoreViewModelV2 class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewModelProtocol { - private let appSettings: AppSettings + private let userSettings: UserSettings private let clientProxy: ClientProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol @@ -22,26 +22,26 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo actionsSubject.eraseToAnyPublisher() } - init(userSession: UserSessionProtocol, appSettings: AppSettings, isBugReportServiceEnabled: Bool, isInSecondaryWindow: Bool, userIndicatorController: UserIndicatorControllerProtocol) { - self.appSettings = appSettings + init(userSession: UserSessionProtocol, userSettings: UserSettings, isBugReportServiceEnabled: Bool, isInSecondaryWindow: Bool, userIndicatorController: UserIndicatorControllerProtocol) { + self.userSettings = userSettings clientProxy = userSession.clientProxy self.userIndicatorController = userIndicatorController super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID, userProfile: userSession.clientProxy.userProfilePublisher.value, - showLinkNewDeviceButton: appSettings.linkNewDeviceEnabled, + showLinkNewDeviceButton: userSettings.linkNewDeviceEnabled, showAccountDeactivation: userSession.clientProxy.canDeactivateAccount, - showDeveloperOptions: appSettings.developerOptionsEnabled, - showAnalyticsSettings: appSettings.canPromptForAnalytics, + showDeveloperOptions: userSettings.developerOptionsEnabled, + showAnalyticsSettings: userSettings.canPromptForAnalytics, isBugReportServiceEnabled: isBugReportServiceEnabled, navigationBarVisibility: isInSecondaryWindow ? .hidden : .automatic), mediaProvider: userSession.mediaProvider) - appSettings.developerOptionsEnabledPublisher + userSettings.developerOptionsEnabledPublisher .weakAssign(to: \.state.showDeveloperOptions, on: self) .store(in: &cancellables) - appSettings.linkNewDeviceEnabledPublisher + userSettings.linkNewDeviceEnabledPublisher .weakAssign(to: \.state.showLinkNewDeviceButton, on: self) .store(in: &cancellables) @@ -138,7 +138,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo case .labs: actionsSubject.send(.labs) case .enableDeveloperOptions: - appSettings.developerOptionsEnabled.toggle() + userSettings.developerOptionsEnabled.toggle() case .developerOptions: actionsSubject.send(.developerOptions) case .deactivateAccount: diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift index 3e9b3d6e6..b58a3bf01 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift @@ -313,7 +313,7 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview { displayName: "Alice Liddell", status: .mockFocussing)))) return SettingsScreenViewModel(userSession: userSession, - appSettings: .volatile(), + userSettings: .volatile(), isBugReportServiceEnabled: isBugReportServiceEnabled, isInSecondaryWindow: false, userIndicatorController: UserIndicatorControllerMock()) diff --git a/ElementX/Sources/Screens/Settings/UserDetailsEditScreen/View/UserDetailsEditScreen.swift b/ElementX/Sources/Screens/Settings/UserDetailsEditScreen/View/UserDetailsEditScreen.swift index aaaecbccd..c7ced1676 100644 --- a/ElementX/Sources/Screens/Settings/UserDetailsEditScreen/View/UserDetailsEditScreen.swift +++ b/ElementX/Sources/Screens/Settings/UserDetailsEditScreen/View/UserDetailsEditScreen.swift @@ -145,7 +145,7 @@ struct UserDetailsEditScreen_Previews: PreviewProvider, TestablePreview { canChangeDisplayName: canChangeProfile)))) return UserDetailsEditScreenViewModel(userSession: userSession, - mediaUploadingPreprocessor: .init(appSettings: .volatile()), + mediaUploadingPreprocessor: .init(userSettings: .volatile()), userIndicatorController: UserIndicatorControllerMock()) } } diff --git a/ElementX/Sources/Screens/Spaces/SpaceSettingsScreen/View/SpaceSettingsScreen.swift b/ElementX/Sources/Screens/Spaces/SpaceSettingsScreen/View/SpaceSettingsScreen.swift index 000ba732e..38e5b2500 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceSettingsScreen/View/SpaceSettingsScreen.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceSettingsScreen/View/SpaceSettingsScreen.swift @@ -132,7 +132,7 @@ struct SpaceSettingsScreen_Previews: PreviewProvider, TestablePreview { canonicalAlias: "#space:matrix.org", members: members)), userSession: UserSessionMock(.init()), - appSettings: AppSettings.volatile(), + userSettings: UserSettings.volatile(), appHooks: AppHooks(), analyticsService: AnalyticsServiceMock(.init()), userIndicatorController: UserIndicatorControllerMock(), diff --git a/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift b/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift index 08591b7c4..edb6f6814 100644 --- a/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift +++ b/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift @@ -154,7 +154,7 @@ struct StartChatScreen: View { struct StartChatScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = { - let appSettings = AppSettings.volatile() + let userSettings = UserSettings.volatile() let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com")))) let userDiscoveryService = UserDiscoveryServiceMock() userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice]) diff --git a/ElementX/Sources/Screens/ThreadTimelineScreen/ThreadTimelineScreenCoordinator.swift b/ElementX/Sources/Screens/ThreadTimelineScreen/ThreadTimelineScreenCoordinator.swift index ed72f791a..593910121 100644 --- a/ElementX/Sources/Screens/ThreadTimelineScreen/ThreadTimelineScreenCoordinator.swift +++ b/ElementX/Sources/Screens/ThreadTimelineScreen/ThreadTimelineScreenCoordinator.swift @@ -21,7 +21,7 @@ struct ThreadTimelineScreenCoordinatorParameters { let linkMetadataProvider: LinkMetadataProviderProtocol let completionSuggestionService: CompletionSuggestionServiceProtocol let appMediator: AppMediatorProtocol - let appSettings: AppSettings + let userSettings: UserSettings let analytics: AnalyticsServiceProtocol let composerDraftService: ComposerDraftServiceProtocol let timelineControllerFactory: TimelineControllerFactoryProtocol @@ -46,7 +46,7 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol { private let viewModel: ThreadTimelineScreenViewModelProtocol private let timelineViewModel: TimelineViewModelProtocol private var composerViewModel: ComposerToolbarViewModelProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private var cancellables = Set() @@ -56,7 +56,7 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol { } init(parameters: ThreadTimelineScreenCoordinatorParameters) { - appSettings = parameters.appSettings + userSettings = parameters.userSettings viewModel = ThreadTimelineScreenViewModel(roomProxy: parameters.roomProxy, userSession: parameters.userSession) @@ -67,7 +67,6 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol { mediaPlayerProvider: parameters.mediaPlayerProvider, userIndicatorController: parameters.userIndicatorController, appMediator: parameters.appMediator, - appSettings: parameters.appSettings, analyticsService: parameters.analytics, emojiProvider: parameters.emojiProvider, linkMetadataProvider: parameters.linkMetadataProvider, @@ -84,7 +83,7 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol { completionSuggestionService: parameters.completionSuggestionService, mediaProvider: parameters.userSession.mediaProvider, mentionDisplayHelper: ComposerMentionDisplayHelper(timelineContext: timelineViewModel.context), - appSettings: parameters.appSettings, + userSettings: parameters.userSettings, analyticsService: parameters.analytics, composerDraftService: parameters.composerDraftService) } @@ -110,13 +109,13 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol { case .displayReportContent(let itemID, let senderID): actionsSubject.send(.presentReportContent(itemID: itemID, senderID: senderID)) case .displayCameraPicker: - actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .camera, selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)), + actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .camera, selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)), caption: composerViewModel.context.plainComposerText)) case .displayMediaPicker: - actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .photoLibrary, selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)), + actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .photoLibrary, selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)), caption: composerViewModel.context.plainComposerText)) case .displayDocumentPicker: - actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .documents(), selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)), + actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .documents(), selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)), caption: composerViewModel.context.plainComposerText)) case .displayMediaPreview(let mediaPreviewViewModel): viewModel.displayMediaPreview(mediaPreviewViewModel) diff --git a/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift b/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift index 4df3334b3..1247ec668 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift @@ -40,7 +40,7 @@ class TimelineInteractionHandler { private let voiceMessageRecorder: VoiceMessageRecorderProtocol private let userIndicatorController: UserIndicatorControllerProtocol private let appMediator: AppMediatorProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let analyticsService: AnalyticsServiceProtocol private let emojiProvider: EmojiProviderProtocol private let linkMetadataProvider: LinkMetadataProviderProtocol @@ -78,7 +78,6 @@ class TimelineInteractionHandler { voiceMessageRecorder: VoiceMessageRecorderProtocol, userIndicatorController: UserIndicatorControllerProtocol, appMediator: AppMediatorProtocol, - appSettings: AppSettings, analyticsService: AnalyticsServiceProtocol, emojiProvider: EmojiProviderProtocol, linkMetadataProvider: LinkMetadataProviderProtocol, @@ -90,7 +89,7 @@ class TimelineInteractionHandler { self.voiceMessageRecorder = voiceMessageRecorder self.userIndicatorController = userIndicatorController self.appMediator = appMediator - self.appSettings = appSettings + userSettings = userSession.userSettings self.analyticsService = analyticsService self.emojiProvider = emojiProvider self.linkMetadataProvider = linkMetadataProvider @@ -456,8 +455,8 @@ class TimelineInteractionHandler { // MARK: Audio Playback func changePlaybackSpeed(for itemID: TimelineItemIdentifier) { - let nextSpeed = appSettings.voiceMessagePlaybackSpeed.next - appSettings.voiceMessagePlaybackSpeed = nextSpeed + let nextSpeed = userSettings.voiceMessagePlaybackSpeed.next + userSettings.voiceMessagePlaybackSpeed = nextSpeed audioPlayerState(for: itemID)?.setPlaybackSpeed(nextSpeed) } @@ -589,8 +588,8 @@ class TimelineInteractionHandler { title: L10n.commonVoiceMessage, duration: voiceMessageRoomTimelineItem.content.duration, waveform: voiceMessageRoomTimelineItem.content.waveform, - playbackSpeed: appSettings.voiceMessagePlaybackSpeed, - playbackSpeedPublisher: appSettings.voiceMessagePlaybackSpeedPublisher) + playbackSpeed: userSettings.voiceMessagePlaybackSpeed, + playbackSpeedPublisher: userSettings.voiceMessagePlaybackSpeedPublisher) mediaPlayerProvider.register(audioPlayerState: playerState) return playerState } @@ -711,7 +710,6 @@ class TimelineInteractionHandler { mediaPlayerProvider: mediaPlayerProvider, userIndicatorController: userIndicatorController, appMediator: appMediator, - appSettings: appSettings, analyticsService: analyticsService, emojiProvider: emojiProvider, linkMetadataProvider: linkMetadataProvider, diff --git a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift index d7fd84ea6..4ef6f9580 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift @@ -29,7 +29,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { private let mediaPlayerProvider: MediaPlayerProviderProtocol private let userIndicatorController: UserIndicatorControllerProtocol private let appMediator: AppMediatorProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let analyticsService: AnalyticsServiceProtocol private let emojiProvider: EmojiProviderProtocol @@ -54,7 +54,6 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { mediaPlayerProvider: MediaPlayerProviderProtocol, userIndicatorController: UserIndicatorControllerProtocol, appMediator: AppMediatorProtocol, - appSettings: AppSettings, analyticsService: AnalyticsServiceProtocol, emojiProvider: EmojiProviderProtocol, linkMetadataProvider: LinkMetadataProviderProtocol, @@ -63,7 +62,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { self.timelineController = timelineController self.userSession = userSession self.mediaPlayerProvider = mediaPlayerProvider - self.appSettings = appSettings + userSettings = userSession.userSettings self.analyticsService = analyticsService self.userIndicatorController = userIndicatorController self.appMediator = appMediator @@ -78,7 +77,6 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { voiceMessageRecorder: voiceMessageRecorder, userIndicatorController: userIndicatorController, appMediator: appMediator, - appSettings: appSettings, analyticsService: analyticsService, emojiProvider: emojiProvider, linkMetadataProvider: linkMetadataProvider, @@ -99,16 +97,16 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { timelineState: TimelineState(focussedEvent: focussedEventID.map { .init(eventID: $0, appearance: .immediate) }), ownUserID: roomProxy.ownUserID, hideTimelineMedia: hideTimelineMedia, - isViewSourceEnabled: appSettings.viewSourceEnabled, - areThreadsEnabled: appSettings.threadsEnabled, - linkPreviewsEnabled: appSettings.linkPreviewsEnabled, - jumpToReadMarkerEnabled: appSettings.jumpToReadMarkerEnabled, - messageSelection: .init(isEnabled: appSettings.messageMultiSelectEnabled), + isViewSourceEnabled: userSettings.viewSourceEnabled, + areThreadsEnabled: userSettings.threadsEnabled, + linkPreviewsEnabled: userSettings.linkPreviewsEnabled, + jumpToReadMarkerEnabled: userSettings.jumpToReadMarkerEnabled, + messageSelection: .init(isEnabled: userSettings.messageMultiSelectEnabled), hasPredecessor: roomProxy.predecessorRoom != nil, pinnedEventIDs: roomProxy.infoPublisher.value.pinnedEventIDs, emojiProvider: emojiProvider, linkMetadataProvider: hideTimelineMedia ? nil : linkMetadataProvider, - mapTilerConfiguration: appSettings.mapTilerConfiguration.publisher.value, + mapTilerConfiguration: userSettings.mapTilerConfiguration.publisher.value, bindings: .init(reactionsCollapsed: [:])), mediaProvider: userSession.mediaProvider, contentScannerService: userSession.contentScannerService) @@ -274,7 +272,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { case .voiceMessage(let voiceMessageAction): processVoiceMessageAction(voiceMessageAction) case .contentChanged(let isEmpty): - guard appSettings.sharePresence else { + guard userSettings.sharePresence else { return } @@ -501,7 +499,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { } .store(in: &cancellables) - setupAppSettingsSubscriptions() + setupUserSettingsSubscriptions() roomProxy.membersPublisher .receive(on: DispatchQueue.main) @@ -510,7 +508,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { roomProxy.typingMembersPublisher .receive(on: DispatchQueue.main) - .filter { [weak self] _ in self?.appSettings.sharePresence ?? false } + .filter { [weak self] _ in self?.userSettings.sharePresence ?? false } .weakAssign(to: \.state.typingMembers, on: self) .store(in: &cancellables) @@ -562,7 +560,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { func viewInRoomTimeline(eventID: String) async { switch await roomProxy.loadOrFetchEventDetails(for: eventID) { case .success(let event): - let threadRootEventID: String? = if appSettings.threadsEnabled { + let threadRootEventID: String? = if userSettings.threadsEnabled { event.threadRootEventId() } else { nil @@ -573,20 +571,20 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { } } - private func setupAppSettingsSubscriptions() { - appSettings.sharePresencePublisher + private func setupUserSettingsSubscriptions() { + userSettings.sharePresencePublisher .weakAssign(to: \.state.showReadReceipts, on: self) .store(in: &cancellables) - appSettings.viewSourceEnabledPublisher + userSettings.viewSourceEnabledPublisher .weakAssign(to: \.state.isViewSourceEnabled, on: self) .store(in: &cancellables) - appSettings.threadsEnabledPublisher + userSettings.threadsEnabledPublisher .weakAssign(to: \.state.areThreadsEnabled, on: self) .store(in: &cancellables) - appSettings.jumpToReadMarkerEnabledPublisher + userSettings.jumpToReadMarkerEnabledPublisher .weakAssign(to: \.state.jumpToReadMarkerEnabled, on: self) .store(in: &cancellables) @@ -1148,7 +1146,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { primaryButton: .init(title: L10n.actionOk, action: nil), secondaryButton: .init(title: L10n.actionLearnMore) { [weak self] in guard let self else { return } - appMediator.open(appSettings.historySharingDetailsURL) + appMediator.open(userSettings.historySharingDetailsURL) }) case .inviteAgain: state.bindings.alertInfo = .init(id: .inviteAgain, @@ -1199,7 +1197,7 @@ extension TimelineViewModel { extension TimelineViewModel { private func setupSelectionSubscriptions() { - appSettings.messageMultiSelectEnabledPublisher + userSettings.messageMultiSelectEnabledPublisher .sink { [weak self] isEnabled in self?.state.messageSelection.isEnabled = isEnabled if !isEnabled { @@ -1300,8 +1298,6 @@ extension TimelineViewModel { clientProxyMock.roomSummaryForIdentifierReturnValue = .mock(id: "!room:matrix.org", name: "Room", canonicalAlias: "#room:matrix.org") let roomProxy = JoinedRoomProxyMock(.init(name: "Preview room", predecessor: hasPredecessor ? .init(roomId: UUID().uuidString) : nil)) - let appSettings = AppSettings.volatile() - return TimelineViewModel(roomProxy: roomProxy, focussedEventID: nil, timelineController: timelineController ?? TimelineControllerMock(.init(timelineKind: timelineKind)), @@ -1309,9 +1305,8 @@ extension TimelineViewModel { mediaPlayerProvider: MediaPlayerProviderMock(), userIndicatorController: UserIndicatorControllerMock(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), timelineControllerFactory: TimelineControllerFactoryMock(.init())) } diff --git a/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenu.swift b/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenu.swift index d9a418832..09611dccc 100644 --- a/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenu.swift +++ b/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenu.swift @@ -340,7 +340,7 @@ struct TimelineItemMenu_Previews: PreviewProvider, TestablePreview { isViewSourceEnabled: true, areThreadsEnabled: true, timelineKind: .live, - emojiProvider: EmojiProvider(appSettings: .volatile())) + emojiProvider: EmojiProvider(userSettings: .volatile())) guard let actions = provider.makeActions() else { return nil } if var textItem = item as? TextRoomTimelineItem { diff --git a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift index 07f90ffbd..b309ce8e4 100644 --- a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift +++ b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift @@ -45,17 +45,14 @@ struct ReadReceiptsSummaryView_Previews: PreviewProvider, TestablePreview { ] let roomProxyMock = JoinedRoomProxyMock(.init(name: "Room", members: members)) - let appSettings = AppSettings.volatile() - return TimelineViewModel(roomProxy: roomProxyMock, timelineController: TimelineControllerMock(.init()), userSession: UserSessionMock(.init()), mediaPlayerProvider: MediaPlayerProviderMock(), userIndicatorController: UserIndicatorControllerMock(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), timelineControllerFactory: TimelineControllerFactoryMock(.init())) }() diff --git a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift index 2fa74ea13..7b1347c3a 100644 --- a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift +++ b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift @@ -421,39 +421,39 @@ private extension TimelineItemKeyForwarder { struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview { static let viewModel: TimelineViewModel = { - let appSettings = AppSettings.volatile() - appSettings.threadsEnabled = true + let userSettings = UserSettings.volatile() + userSettings.threadsEnabled = true + let userSession = UserSessionMock(.init(userSettings: userSettings)) let roomProxy = JoinedRoomProxyMock(.init()) return TimelineViewModel(roomProxy: roomProxy, focussedEventID: nil, timelineController: TimelineControllerMock(.init()), - userSession: UserSessionMock(.init()), + userSession: userSession, mediaPlayerProvider: MediaPlayerProviderMock(), userIndicatorController: UserIndicatorControllerMock(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: userSettings), linkMetadataProvider: LinkMetadataProvider(), timelineControllerFactory: TimelineControllerFactoryMock(.init())) }() static let viewModelWithPins: TimelineViewModel = { - let appSettings = AppSettings.volatile() - appSettings.threadsEnabled = true + let userSettings = UserSettings.volatile() + userSettings.threadsEnabled = true + let userSession = UserSessionMock(.init(userSettings: userSettings)) let roomProxy = JoinedRoomProxyMock(.init(name: "Preview Room", pinnedEventIDs: ["pinned"])) return TimelineViewModel(roomProxy: roomProxy, focussedEventID: nil, timelineController: TimelineControllerMock(.init()), - userSession: UserSessionMock(.init()), + userSession: userSession, mediaPlayerProvider: MediaPlayerProviderMock(), userIndicatorController: UserIndicatorControllerMock(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: userSettings), linkMetadataProvider: LinkMetadataProvider(), timelineControllerFactory: TimelineControllerFactoryMock(.init())) }() @@ -461,19 +461,19 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview static let unsafeViewModel = TimelineViewModel.mock(contentScannerService: ContentScannerServiceMock(.init(scanResult: false))) static let selectingViewModel: TimelineViewModel = { - let appSettings = AppSettings.volatile() - appSettings.messageMultiSelectEnabled = true + let userSettings = UserSettings.volatile() + userSettings.messageMultiSelectEnabled = true + let userSession = UserSessionMock(.init(userSettings: userSettings)) let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init()), focussedEventID: nil, timelineController: TimelineControllerMock(.init()), - userSession: UserSessionMock(.init()), + userSession: userSession, mediaPlayerProvider: MediaPlayerProviderMock(), userIndicatorController: UserIndicatorControllerMock(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: userSettings), linkMetadataProvider: LinkMetadataProvider(), timelineControllerFactory: TimelineControllerFactoryMock(.init())) viewModel.state.messageSelection.selectedEventIDs = ["selected"] diff --git a/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift b/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift index 1d1426ceb..cc9965a19 100644 --- a/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift +++ b/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift @@ -79,21 +79,16 @@ struct TimelineReadReceiptsView_Previews: PreviewProvider, TestablePreview { .mockMe ] - static let viewModel = { - let appSettings = AppSettings.volatile() - - return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Test", members: members)), - timelineController: TimelineControllerMock(.init()), - userSession: UserSessionMock(.init()), - mediaPlayerProvider: MediaPlayerProviderMock(), - userIndicatorController: UserIndicatorControllerMock(), - appMediator: AppMediatorMock(.init()), - appSettings: appSettings, - analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), - linkMetadataProvider: LinkMetadataProvider(), - timelineControllerFactory: TimelineControllerFactoryMock(.init())) - }() + static let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Test", members: members)), + timelineController: TimelineControllerMock(.init()), + userSession: UserSessionMock(.init()), + mediaPlayerProvider: MediaPlayerProviderMock(), + userIndicatorController: UserIndicatorControllerMock(), + appMediator: AppMediatorMock(.init()), + analyticsService: AnalyticsServiceMock(.init()), + emojiProvider: EmojiProvider(userSettings: .volatile()), + linkMetadataProvider: LinkMetadataProvider(), + timelineControllerFactory: TimelineControllerFactoryMock(.init())) static let singleReceipt = [ReadReceipt(userID: RoomMemberProxyMock.mockAlice.userID, formattedTimestamp: "Now")] static let doubleReceipt = [ReadReceipt(userID: RoomMemberProxyMock.mockAlice.userID, formattedTimestamp: "Now"), diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift index 5474d38ce..39d415b1a 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift @@ -89,22 +89,17 @@ struct HighlightedTimelineItemTimeline_Previews: PreviewProvider { static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock) static let focussedEventID = "TimelineFixtures.default.5" static let composerViewModel = ComposerToolbarViewModel.mock() - static let timelineViewModel = { - let appSettings = AppSettings.volatile() - - return TimelineViewModel(roomProxy: roomProxyMock, - focussedEventID: focussedEventID, - timelineController: TimelineControllerMock(.init()), - userSession: UserSessionMock(.init()), - mediaPlayerProvider: MediaPlayerProviderMock(), - userIndicatorController: UserIndicatorControllerMock(), - appMediator: AppMediatorMock(.init()), - appSettings: appSettings, - analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), - linkMetadataProvider: LinkMetadataProvider(), - timelineControllerFactory: TimelineControllerFactoryMock(.init())) - }() + static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock, + focussedEventID: focussedEventID, + timelineController: TimelineControllerMock(.init()), + userSession: UserSessionMock(.init()), + mediaPlayerProvider: MediaPlayerProviderMock(), + userIndicatorController: UserIndicatorControllerMock(), + appMediator: AppMediatorMock(.init()), + analyticsService: AnalyticsServiceMock(.init()), + emojiProvider: EmojiProvider(userSettings: .volatile()), + linkMetadataProvider: LinkMetadataProvider(), + timelineControllerFactory: TimelineControllerFactoryMock(.init())) static var previews: some View { ElementNavigationStack { diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineView.swift index 42e207ef2..f4220f11c 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineView.swift @@ -155,21 +155,16 @@ struct TimelineView_Previews: PreviewProvider { // Not testable as this preview name: "Preview room")) static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock) static let composerViewModel = ComposerToolbarViewModel.mock() - static let timelineViewModel = { - let appSettings = AppSettings.volatile() - - return TimelineViewModel(roomProxy: roomProxyMock, - timelineController: TimelineControllerMock(.init()), - userSession: UserSessionMock(.init()), - mediaPlayerProvider: MediaPlayerProviderMock(), - userIndicatorController: UserIndicatorControllerMock(), - appMediator: AppMediatorMock(.init()), - appSettings: appSettings, - analyticsService: AnalyticsServiceMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), - linkMetadataProvider: LinkMetadataProvider(), - timelineControllerFactory: TimelineControllerFactoryMock(.init())) - }() + static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock, + timelineController: TimelineControllerMock(.init()), + userSession: UserSessionMock(.init()), + mediaPlayerProvider: MediaPlayerProviderMock(), + userIndicatorController: UserIndicatorControllerMock(), + appMediator: AppMediatorMock(.init()), + analyticsService: AnalyticsServiceMock(.init()), + emojiProvider: EmojiProvider(userSettings: .volatile()), + linkMetadataProvider: LinkMetadataProvider(), + timelineControllerFactory: TimelineControllerFactoryMock(.init())) static var previews: some View { ElementNavigationStack { diff --git a/ElementX/Sources/Services/AlertTones/NotificationToneManager.swift b/ElementX/Sources/Services/AlertTones/NotificationToneManager.swift index 6421740ff..33394e45f 100644 --- a/ElementX/Sources/Services/AlertTones/NotificationToneManager.swift +++ b/ElementX/Sources/Services/AlertTones/NotificationToneManager.swift @@ -29,7 +29,7 @@ nonisolated struct NotificationToneManager: NotificationToneManagerProtocol { case bufferCreationFailed } - private let appSettings: AppSettings + private let userSettings: UserSettings /// The default Element X bundled message tone. static let defaultElementXMessageTone: NotificationTone = .createBundledSound(label: L10n.screenNotificationSettingsSoundElementDefault, @@ -45,8 +45,8 @@ nonisolated struct NotificationToneManager: NotificationToneManagerProtocol { nonisolated static let libraryLocation = URL.libraryDirectory.appending(components: "Sounds", "AvailableSounds", directoryHint: .isDirectory) /// Creates the manager and ensures required library directories exist. - init(appSettings: AppSettings) { - self.appSettings = appSettings + init(userSettings: UserSettings) { + self.userSettings = userSettings do { try FileManager.default.createDirectory(at: NotificationToneManager.libraryLocation, withIntermediateDirectories: true) @@ -67,12 +67,12 @@ nonisolated struct NotificationToneManager: NotificationToneManagerProtocol { try? FileManager.default.removeItem(at: Self.selectedToneLocation) let toneLocation = Self.toneLocation(for: alertTone) try FileManager.default.copyItem(at: toneLocation, to: Self.selectedToneLocation) - appSettings.selectedNotificationTone = alertTone + userSettings.selectedNotificationTone = alertTone return Self.selectedToneLocation } catch { if (try? Self.selectedToneLocation.checkResourceIsReachable()) != true { // make sure the selected tone is reset if there's no custom tone present - appSettings.selectedNotificationTone = nil + userSettings.selectedNotificationTone = nil } throw error } diff --git a/ElementX/Sources/Services/Client/ClientFactory.swift b/ElementX/Sources/Services/Client/ClientFactory.swift index 3d8548a24..942a86956 100644 --- a/ElementX/Sources/Services/Client/ClientFactory.swift +++ b/ElementX/Sources/Services/Client/ClientFactory.swift @@ -81,7 +81,7 @@ nonisolated struct ClientFactory: ClientFactoryProtocol { func makeNSEClient(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, - appSettings: CommonSettingsProtocol, + userSettings: CommonSettingsProtocol, appHooks: AppHooks) async throws -> ClientProtocol { let homeserverURL = credentials.restorationToken.session.homeserverUrl @@ -90,10 +90,10 @@ nonisolated struct ClientFactory: ClientFactoryProtocol { discoverSlidingSync: false, sessionDelegate: clientSessionDelegate, appHooks: appHooks, - enableOnlySignedDeviceIsolationMode: appSettings.enableOnlySignedDeviceIsolationMode, + enableOnlySignedDeviceIsolationMode: userSettings.enableOnlySignedDeviceIsolationMode, requestTimeout: 15000, maxRequestRetryTime: 5000, - threadsEnabled: appSettings.threadsEnabled) + threadsEnabled: userSettings.threadsEnabled) .systemIsMemoryConstrained() .sqliteStore(config: .init(dataPath: credentials.restorationToken.sessionDirectories.dataPath, cachePath: credentials.restorationToken.sessionDirectories.cachePath) diff --git a/ElementX/Sources/Services/Client/ClientFactoryProtocol.swift b/ElementX/Sources/Services/Client/ClientFactoryProtocol.swift index b539ace42..59d430963 100644 --- a/ElementX/Sources/Services/Client/ClientFactoryProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientFactoryProtocol.swift @@ -36,6 +36,6 @@ nonisolated protocol ClientFactoryProtocol { func makeNSEClient(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, - appSettings: CommonSettingsProtocol, + userSettings: CommonSettingsProtocol, appHooks: AppHooks) async throws -> ClientProtocol } diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 59d663f28..5b6c22b9a 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -17,7 +17,7 @@ import OrderedCollections class ClientProxy: ClientProxyProtocol { private let client: ClientProtocol private let networkMonitor: NetworkMonitorProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let analyticsService: AnalyticsServiceProtocol let mediaLoader: MediaLoaderProtocol @@ -206,11 +206,11 @@ class ClientProxy: ClientProxyProtocol { init(client: ClientProtocol, networkMonitor: NetworkMonitorProtocol, - appSettings: AppSettings, + userSettings: UserSettings, analyticsService: AnalyticsServiceProtocol) async throws { self.client = client self.networkMonitor = networkMonitor - self.appSettings = appSettings + self.userSettings = userSettings self.analyticsService = analyticsService userProfileSubject = .init(UserProfile(userID: (try? client.userId()) ?? "")) @@ -219,7 +219,7 @@ class ClientProxy: ClientProxyProtocol { // Route media downloads through a content scanner when one has been configured for the server, // and expose a proxy for the active scanning of content in the timeline. - if let contentScannerURL = appSettings.contentScannerURL.publisher.value, let client = client as? Client { + if let contentScannerURL = userSettings.contentScannerURL.publisher.value, let client = client as? Client { let scanner = ContentScanner(scannerUrl: contentScannerURL.absoluteString) await client.setContentScanner(contentScanner: scanner) contentScanner = ContentScannerProxy(contentScanner: scanner, client: client) @@ -244,7 +244,7 @@ class ClientProxy: ClientProxyProtocol { let configuredAppService = try await ClientProxyServices(client: client, notificationSettings: notificationSettings, - appSettings: appSettings) + userSettings: userSettings) syncService = configuredAppService.syncService roomListService = configuredAppService.roomListService @@ -495,7 +495,7 @@ class ClientProxy: ClientProxyProtocol { do { let parameters = CreateRoomParameters(name: nil, topic: nil, - isEncrypted: !appSettings.forceDisableE2EE.publisher.value, + isEncrypted: !userSettings.forceDisableE2EE.publisher.value, isDirect: true, visibility: .private, preset: .trustedPrivateChat, @@ -538,7 +538,7 @@ class ClientProxy: ClientProxyProtocol { let parameters = CreateRoomParameters(name: name, topic: topic, - isEncrypted: !appSettings.forceDisableE2EE.publisher.value && accessType.isEncrypted, + isEncrypted: !userSettings.forceDisableE2EE.publisher.value && accessType.isEncrypted, isDirect: false, visibility: accessType.visibility, preset: accessType.preset, @@ -1158,7 +1158,7 @@ class ClientProxy: ClientProxyProtocol { private func reconcileServiceState() async { switch desiredServiceState { case .running(let offline): - if appSettings.clientPausingAndResumingEnabled { + if userSettings.clientPausingAndResumingEnabled { do { MXLog.info("Resuming client") try await client.resume() @@ -1192,7 +1192,7 @@ class ClientProxy: ClientProxyProtocol { await syncService.stop() MXLog.info("Sync stopped") - if appSettings.clientPausingAndResumingEnabled { + if userSettings.clientPausingAndResumingEnabled { do { MXLog.info("Pausing client") try await client.pause() @@ -1375,7 +1375,7 @@ class ClientProxy: ClientProxyProtocol { case .joined: let roomProxy = try await JoinedRoomProxy(roomListService: roomListService, room: room, - appSettings: appSettings, + userSettings: userSettings, analyticsService: analyticsService, eventStringBuilder: eventStringBuilder) @@ -1531,7 +1531,7 @@ private struct ClientProxyServices { init(client: ClientProtocol, notificationSettings: NotificationSettingsProxyProtocol, - appSettings: AppSettings) async throws { + userSettings: UserSettings) async throws { let syncService = try await client .syncService() .withOfflineMode() @@ -1553,21 +1553,21 @@ private struct ClientProxyServices { name: "AllRooms", shouldUpdateVisibleRange: true, notificationSettings: notificationSettings, - appSettings: appSettings) + userSettings: userSettings) try await roomSummaryProvider.setRoomList(roomListService.allRooms()) alternateRoomSummaryProvider = RoomSummaryProvider(roomListService: roomListService, eventStringBuilder: eventStringBuilder, name: "AlternateAllRooms", notificationSettings: notificationSettings, - appSettings: appSettings) + userSettings: userSettings) staticRoomSummaryProvider = RoomSummaryProvider(roomListService: roomListService, eventStringBuilder: eventStringBuilder, name: "StaticAllRooms", roomListPageSize: .max, notificationSettings: notificationSettings, - appSettings: appSettings) + userSettings: userSettings) // Setting a provider's room list will create summaries for every room so // wait until the app is fully running for the alternate and static providers. diff --git a/ElementX/Sources/Services/Emojis/EmojiProvider.swift b/ElementX/Sources/Services/Emojis/EmojiProvider.swift index 0815e0df9..98f51bd0d 100644 --- a/ElementX/Sources/Services/Emojis/EmojiProvider.swift +++ b/ElementX/Sources/Services/Emojis/EmojiProvider.swift @@ -12,13 +12,13 @@ import Foundation class EmojiProvider: EmojiProviderProtocol { private let maxFrequentEmojis = 20 private let loader: EmojiLoaderProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private(set) var state: EmojiProviderState = .notLoaded - init(loader: EmojiLoaderProtocol = EmojibaseDatasource(), appSettings: AppSettings) { + init(loader: EmojiLoaderProtocol = EmojibaseDatasource(), userSettings: UserSettings) { self.loader = loader - self.appSettings = appSettings + self.userSettings = userSettings Task { await loadIfNeeded() @@ -61,7 +61,7 @@ class EmojiProvider: EmojiProviderProtocol { return [] } - return appSettings.frequentlyUsedSystemEmojis.map(\.key) + return userSettings.frequentlyUsedSystemEmojis.map(\.key) } func markEmojiAsFrequentlyUsed(_ emoji: String) { @@ -70,9 +70,9 @@ class EmojiProvider: EmojiProviderProtocol { } let frequentlyUsed = if !frequentlyUsedSystemEmojis().contains(emoji) { - appSettings.frequentlyUsedSystemEmojis + [.init(count: 0, key: emoji)] + userSettings.frequentlyUsedSystemEmojis + [.init(count: 0, key: emoji)] } else { - appSettings.frequentlyUsedSystemEmojis.map { frequentlyUsedEmoji in + userSettings.frequentlyUsedSystemEmojis.map { frequentlyUsedEmoji in if frequentlyUsedEmoji.key == emoji { return FrequentlyUsedEmoji(count: frequentlyUsedEmoji.count + 1, key: emoji) } @@ -81,7 +81,7 @@ class EmojiProvider: EmojiProviderProtocol { } } - appSettings.frequentlyUsedSystemEmojis = frequentlyUsed.sorted { $0.count > $1.count } + userSettings.frequentlyUsedSystemEmojis = frequentlyUsed.sorted { $0.count > $1.count } } // MARK: - Private diff --git a/ElementX/Sources/Services/Location/LiveLocationManager.swift b/ElementX/Sources/Services/Location/LiveLocationManager.swift index 250ede223..cd9c8eae0 100644 --- a/ElementX/Sources/Services/Location/LiveLocationManager.swift +++ b/ElementX/Sources/Services/Location/LiveLocationManager.swift @@ -11,7 +11,7 @@ import CoreLocation class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationManagerDelegate { private let clientProxy: ClientProxyProtocol private let locationManager: CLLocationManagerProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let authorizationStatusSubject: CurrentValueSubject var authorizationStatus: CurrentValuePublisher { @@ -42,10 +42,10 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana private var lastLocation: CLLocationCoordinate2D? init(clientProxy: ClientProxyProtocol, - appSettings: AppSettings, + userSettings: UserSettings, locationManager: @autoclosure @MainActor () -> CLLocationManagerProtocol = CLLocationManager()) { self.clientProxy = clientProxy - self.appSettings = appSettings + self.userSettings = userSettings // Very important, the CLLocationManager needs to be initialised on the main thread // or the delegate functions won't be handled! // https://developer.apple.com/documentation/corelocation/cllocationmanagerdelegate @@ -64,7 +64,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana // https://developer.apple.com/documentation/corelocation/cllocationmanager/pauseslocationupdatesautomatically self.locationManager.pausesLocationUpdatesAutomatically = false - setupMinimumDistanceUpdatesAndAccuracy(minimumDistance: appSettings.liveLocationMinimumDistanceUpdate) + setupMinimumDistanceUpdatesAndAccuracy(minimumDistance: userSettings.liveLocationMinimumDistanceUpdate) setupSubscriptions() } @@ -72,8 +72,8 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana @discardableResult func requestAlwaysAuthorizationIfPossible() -> Bool { - guard !appSettings.hasRequestedLocationAlwaysLocationAuthorization else { return false } - appSettings.hasRequestedLocationAlwaysLocationAuthorization = true + guard !userSettings.hasRequestedLocationAlwaysLocationAuthorization else { return false } + userSettings.hasRequestedLocationAlwaysLocationAuthorization = true locationManager.requestAlwaysAuthorization() return true } @@ -81,7 +81,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana func startLiveLocation(roomID: String, duration: Duration) async -> Result { // Stop any existing session for this room first var didAlreadyStopLocalSession = false - if appSettings.liveLocationSharingSessionsByRoomID[roomID] != nil + if userSettings.liveLocationSharingSessionsByRoomID[roomID] != nil || startingLiveLocationSharingSessionsByRoomID[roomID] != nil { await stopLiveLocation(roomID: roomID) didAlreadyStopLocalSession = true @@ -114,7 +114,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana var roomProxy: JoinedRoomProxyProtocol? let cachedRoomProxy = activeRoomProxies[roomID] startingLiveLocationSharingSessionsByRoomID.removeValue(forKey: roomID) - appSettings.liveLocationSharingSessionsByRoomID.removeValue(forKey: roomID) + userSettings.liveLocationSharingSessionsByRoomID.removeValue(forKey: roomID) if let cachedRoomProxy { roomProxy = cachedRoomProxy @@ -137,7 +137,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana // If the system resets authorization to notDetermined (e.g. after app reinstall or // settings reset), clear the flag so we can request again. if manager.authorizationStatus == .notDetermined { - appSettings.hasRequestedLocationAlwaysLocationAuthorization = false + userSettings.hasRequestedLocationAlwaysLocationAuthorization = false } // If authorization was revoked, stop all active sessions. @@ -146,7 +146,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana } // Accuracy authorization may have changed, reapply new accuracy settings. - setupMinimumDistanceUpdatesAndAccuracy(minimumDistance: appSettings.liveLocationMinimumDistanceUpdate) + setupMinimumDistanceUpdatesAndAccuracy(minimumDistance: userSettings.liveLocationMinimumDistanceUpdate) authorizationStatusSubject.send(manager.authorizationStatus) } @@ -183,7 +183,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana } .store(in: &cancellables) - appSettings.liveLocationSharingSessionsByRoomIDPublisher + userSettings.liveLocationSharingSessionsByRoomIDPublisher .removeDuplicates() .sink { [weak self] sessions in guard let self else { return } @@ -197,7 +197,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana } .store(in: &cancellables) - appSettings.liveLocationMinimumDistanceUpdatePublisher + userSettings.liveLocationMinimumDistanceUpdatePublisher .removeDuplicates() .debounce(for: .seconds(1), scheduler: DispatchQueue.main) .sink { [weak self] newValue in @@ -210,7 +210,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana // A new beaconInfo has been received in a room with existing active session. // This is either a new start or a new stop from a different device, so we // should remove the session from the current local one. - appSettings.liveLocationSharingSessionsByRoomID.removeValue(forKey: update.roomID) + userSettings.liveLocationSharingSessionsByRoomID.removeValue(forKey: update.roomID) // Instead if we receive a new isLiveUpdate guard update.isLive else { return } @@ -224,7 +224,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana // This means the server has echoed the start of the session and we can safely promote it // to a started session and start sending live locations. startingLiveLocationSharingSessionsByRoomID.removeValue(forKey: update.roomID) - appSettings.liveLocationSharingSessionsByRoomID[update.roomID] = session + userSettings.liveLocationSharingSessionsByRoomID[update.roomID] = session if isUpdatingLocation, let lastLocation { locationUpdateSubject.send(lastLocation) @@ -281,7 +281,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana /// discarding any intermediate updates while always keeping the last one. private func processLocationUpdateIfNeeded() { guard !isProcessingLocationUpdate, let location = latestPendingLocation else { return } - guard !appSettings.liveLocationSharingSessionsByRoomID.isEmpty else { return } + guard !userSettings.liveLocationSharingSessionsByRoomID.isEmpty else { return } latestPendingLocation = nil isProcessingLocationUpdate = true @@ -306,7 +306,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana } private func sendLocationToActiveRooms(_ coordinate: CLLocationCoordinate2D) async { - let sessions = appSettings.liveLocationSharingSessionsByRoomID + let sessions = userSettings.liveLocationSharingSessionsByRoomID let geoURI = GeoURI(coordinate: coordinate, uncertainty: nil) for (roomID, session) in sessions { @@ -351,7 +351,7 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana } private func stopAllSessions() { - let roomIDs = Array(Set(appSettings.liveLocationSharingSessionsByRoomID.keys) + let roomIDs = Array(Set(userSettings.liveLocationSharingSessionsByRoomID.keys) .union(startingLiveLocationSharingSessionsByRoomID.keys)) Task { [weak self] in guard let self else { return } diff --git a/ElementX/Sources/Services/Media/MediaUploadingPreprocessor.swift b/ElementX/Sources/Services/Media/MediaUploadingPreprocessor.swift index 28ca06ed4..2eb4a5c3f 100644 --- a/ElementX/Sources/Services/Media/MediaUploadingPreprocessor.swift +++ b/ElementX/Sources/Services/Media/MediaUploadingPreprocessor.swift @@ -86,7 +86,7 @@ private struct VideoProcessingInfo { } struct MediaUploadingPreprocessor { - let appSettings: AppSettings + let userSettings: UserSettings enum Constants { static let maximumThumbnailSize = CGSize(width: 800, height: 600) @@ -171,7 +171,7 @@ struct MediaUploadingPreprocessor { try stripLocationFromImage(at: url, type: type) var mimeType = mimeType - if appSettings.optimizeMediaUploads, !type.conforms(to: .gif) { + if userSettings.optimizeMediaUploads, !type.conforms(to: .gif) { let outputType = type.conforms(to: .png) ? UTType.png : .jpeg mimeType = outputType.preferredMIMEType ?? "application/octet-stream" try resizeImage(at: url, maxPixelSize: Constants.optimizedMaxPixelSize, destination: url, type: outputType) @@ -439,7 +439,7 @@ struct MediaUploadingPreprocessor { /// - Returns: the URL for the resulting video and its media info as a `VideoProcessingResult` private func convertVideoToMP4(_ url: URL, targetFileSize: UInt) async throws(MediaUploadingPreprocessorError) -> VideoProcessingInfo { let asset = AVURLAsset(url: url) - let presetName = appSettings.optimizeMediaUploads ? AVAssetExportPreset1280x720 : AVAssetExportPreset1920x1080 + let presetName = userSettings.optimizeMediaUploads ? AVAssetExportPreset1280x720 : AVAssetExportPreset1920x1080 guard let exportSession = AVAssetExportSession(asset: asset, presetName: presetName) else { throw .failedConvertingVideo diff --git a/ElementX/Sources/Services/Presence/PresenceService.swift b/ElementX/Sources/Services/Presence/PresenceService.swift index 3f76c24c8..d06ecd0c3 100644 --- a/ElementX/Sources/Services/Presence/PresenceService.swift +++ b/ElementX/Sources/Services/Presence/PresenceService.swift @@ -11,7 +11,7 @@ import UIKit final class PresenceService { private let clientProxy: ClientProxyProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let notificationCenter: NotificationCenter private var isForegroundActive: Bool @@ -22,11 +22,11 @@ final class PresenceService { private var cancellables = Set() init(clientProxy: ClientProxyProtocol, - appSettings: AppSettings, + userSettings: UserSettings, notificationCenter: NotificationCenter = .default, initialApplicationState: UIApplication.State = UIApplication.shared.applicationState) { self.clientProxy = clientProxy - self.appSettings = appSettings + self.userSettings = userSettings self.notificationCenter = notificationCenter isForegroundActive = initialApplicationState == .active @@ -41,7 +41,7 @@ final class PresenceService { } private var desiredPresence: ClientProxyPresence { - switch (isForegroundActive, appSettings.sharePresence) { + switch (isForegroundActive, userSettings.sharePresence) { case (true, true): .online case (true, false): @@ -68,7 +68,7 @@ final class PresenceService { } private func observeSharePresence() { - appSettings.sharePresencePublisher + userSettings.sharePresencePublisher .removeDuplicates() .sink { [weak self] _ in self?.reportCurrentState() diff --git a/ElementX/Sources/Services/Room/JoinedRoomProxy.swift b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift index 17c71f21a..13c18ffdf 100644 --- a/ElementX/Sources/Services/Room/JoinedRoomProxy.swift +++ b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift @@ -14,7 +14,7 @@ import UIKit class JoinedRoomProxy: JoinedRoomProxyProtocol { private let roomListService: RoomListServiceProtocol private let room: RoomProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let analyticsService: AnalyticsServiceProtocol private let eventStringBuilder: RoomEventStringBuilder @@ -71,19 +71,19 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { init(roomListService: RoomListServiceProtocol, room: RoomProtocol, - appSettings: AppSettings, + userSettings: UserSettings, analyticsService: AnalyticsServiceProtocol, eventStringBuilder: RoomEventStringBuilder) async throws { self.roomListService = roomListService self.room = room - self.appSettings = appSettings + self.userSettings = userSettings self.analyticsService = analyticsService self.eventStringBuilder = eventStringBuilder infoSubject = try await .init(RoomInfoProxy(roomInfo: room.roomInfo())) let openRoomSpan = analyticsService.signpost.addSpan(.timelineLoad, toTransaction: .openRoom) - timeline = try await TimelineProxy(timeline: room.timelineWithConfiguration(configuration: .init(focus: .live(hideThreadedEvents: appSettings.threadsEnabled), + timeline = try await TimelineProxy(timeline: room.timelineWithConfiguration(configuration: .init(focus: .live(hideThreadedEvents: userSettings.threadsEnabled), filter: .eventFilter(filter: Self.excludedEventsFilter), internalIdPrefix: nil, dateDividerMode: .daily, @@ -150,7 +150,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { let openRoomSpan = analyticsService.signpost.addSpan(.timelineLoad, toTransaction: .notificationToMessage) let sdkTimeline = try await room.timelineWithConfiguration(configuration: .init(focus: .event(eventId: eventID, numContextEvents: numberOfEvents, - threadMode: .automatic(hideThreadedEvents: appSettings.threadsEnabled)), + threadMode: .automatic(hideThreadedEvents: userSettings.threadsEnabled)), filter: .all, internalIdPrefix: UUID().uuidString, dateDividerMode: .daily, diff --git a/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift b/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift index ef591d986..58ca185e0 100644 --- a/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift +++ b/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProvider.swift @@ -16,7 +16,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { private let name: String private let shouldUpdateVisibleRange: Bool private let notificationSettings: NotificationSettingsProxyProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings private let roomListPageSize: UInt32 /// Remember how many rooms we had on the previous requests so we can deduplicate @@ -68,13 +68,13 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { shouldUpdateVisibleRange: Bool = false, roomListPageSize: UInt32 = 100, notificationSettings: NotificationSettingsProxyProtocol, - appSettings: AppSettings) { + userSettings: UserSettings) { self.roomListService = roomListService self.eventStringBuilder = eventStringBuilder self.name = name self.shouldUpdateVisibleRange = shouldUpdateVisibleRange self.notificationSettings = notificationSettings - self.appSettings = appSettings + self.userSettings = userSettings self.roomListPageSize = roomListPageSize let (diffsStream, diffsContinuation) = AsyncStream<[RoomListEntriesUpdate]>.makeStream() @@ -161,7 +161,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { rustFilters.append(.identifiers(identifiers: Array(roomIDs))) - if !filters.contains(.lowPriority), appSettings.lowPriorityFilterEnabled { + if !filters.contains(.lowPriority), userSettings.lowPriorityFilterEnabled { rustFilters.append(.nonLowPriority) } @@ -169,7 +169,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { case let .all(filters): var rustFilters = filters.map(\.rustFilter) + baseFilter - if !filters.contains(.lowPriority), appSettings.lowPriorityFilterEnabled { + if !filters.contains(.lowPriority), userSettings.lowPriorityFilterEnabled { rustFilters.append(.nonLowPriority) } @@ -180,7 +180,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol { // MARK: - Private private func nameFilter(for query: String) -> [RoomListEntriesDynamicFilterKind] { - appSettings.fuzzyRoomListSearchEnabled ? [.fuzzyMatchRoomName(pattern: query)] : [.normalizedMatchRoomName(pattern: query)] + userSettings.fuzzyRoomListSearchEnabled ? [.fuzzyMatchRoomName(pattern: query)] : [.normalizedMatchRoomName(pattern: query)] } private func setupVisibleRangeObservers() { diff --git a/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift index 6fe267b27..12ccdcf6e 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift @@ -17,7 +17,7 @@ class TimelineController: TimelineControllerProtocol { private let liveTimelineItemProvider: TimelineItemProviderProtocol private let timelineItemFactory: RoomTimelineItemFactoryProtocol private let mediaProvider: MediaProviderProtocol - private let appSettings: AppSettings + private let userSettings: UserSettings let callbacks = PassthroughSubject() @@ -51,14 +51,14 @@ class TimelineController: TimelineControllerProtocol { initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol, mediaProvider: MediaProviderProtocol, - appSettings: AppSettings, + userSettings: UserSettings, allowedGalleryItemTypes: [TimelineAllowedGalleryItemType]? = nil) { self.allowedGalleryItemTypes = allowedGalleryItemTypes self.roomProxy = roomProxy liveTimelineItemProvider = timelineProxy.timelineItemProvider self.timelineItemFactory = timelineItemFactory self.mediaProvider = mediaProvider - self.appSettings = appSettings + self.userSettings = userSettings activeTimeline = timelineProxy activeTimelineItemProvider = liveTimelineItemProvider @@ -127,7 +127,7 @@ class TimelineController: TimelineControllerProtocol { } func sendReadReceipt(for itemID: TimelineItemIdentifier) async { - let receiptType: MatrixRustSDK.ReceiptType = appSettings.sharePresence ? .read : .readPrivate + let receiptType: MatrixRustSDK.ReceiptType = userSettings.sharePresence ? .read : .readPrivate guard let eventID = itemID.eventID else { return diff --git a/ElementX/Sources/Services/Timeline/TimelineController/TimelineControllerFactory.swift b/ElementX/Sources/Services/Timeline/TimelineController/TimelineControllerFactory.swift index 7917773db..9dc20c2e3 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/TimelineControllerFactory.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/TimelineControllerFactory.swift @@ -10,7 +10,7 @@ import Foundation import MatrixRustSDK struct TimelineControllerFactory: TimelineControllerFactoryProtocol { - let appSettings: AppSettings + let userSettings: UserSettings func buildTimelineController(roomProxy: JoinedRoomProxyProtocol, initialFocussedEventID: String?, @@ -21,7 +21,7 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol { initialFocussedEventID: initialFocussedEventID, timelineItemFactory: timelineItemFactory, mediaProvider: mediaProvider, - appSettings: appSettings) + userSettings: userSettings) } func buildThreadTimelineController(threadRootEventID: String, @@ -36,7 +36,7 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol { initialFocussedEventID: initialFocussedEventID, timelineItemFactory: timelineItemFactory, mediaProvider: mediaProvider, - appSettings: appSettings)) + userSettings: userSettings)) case .failure(let error): return .failure(.roomProxyError(error)) } @@ -52,7 +52,7 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol { initialFocussedEventID: nil, timelineItemFactory: timelineItemFactory, mediaProvider: mediaProvider, - appSettings: appSettings)) + userSettings: userSettings)) case .failure(let error): return .failure(.roomProxyError(error)) } @@ -71,7 +71,7 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol { initialFocussedEventID: nil, timelineItemFactory: timelineItemFactory, mediaProvider: mediaProvider, - appSettings: appSettings, + userSettings: userSettings, allowedGalleryItemTypes: allowedMessageTypes.allowedGalleryItemTypes)) case .failure(let error): return .failure(.roomProxyError(error)) diff --git a/ElementX/Sources/UITests/UITestsAppCoordinator.swift b/ElementX/Sources/UITests/UITestsAppCoordinator.swift index 7c721067a..8ac3970f6 100644 --- a/ElementX/Sources/UITests/UITestsAppCoordinator.swift +++ b/ElementX/Sources/UITests/UITestsAppCoordinator.swift @@ -298,12 +298,11 @@ class MockScreen: Identifiable { roomProxy: JoinedRoomProxyMock(.init(name: "Some room name", avatarURL: nil)), timelineController: TimelineControllerMock(.init()), mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -319,12 +318,11 @@ class MockScreen: Identifiable { roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -340,12 +338,11 @@ class MockScreen: Identifiable { roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -360,12 +357,11 @@ class MockScreen: Identifiable { roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -386,12 +382,11 @@ class MockScreen: Identifiable { roomProxy: roomProxy, timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -412,12 +407,11 @@ class MockScreen: Identifiable { roomProxy: roomProxy, timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock()) @@ -437,12 +431,11 @@ class MockScreen: Identifiable { roomProxy: roomProxy, timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -464,12 +457,11 @@ class MockScreen: Identifiable { roomProxy: roomProxy, timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -490,12 +482,11 @@ class MockScreen: Identifiable { roomProxy: roomProxy, timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -512,12 +503,11 @@ class MockScreen: Identifiable { roomProxy: JoinedRoomProxyMock(.init(name: "Timeline highlight", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -547,12 +537,11 @@ class MockScreen: Identifiable { roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -569,12 +558,11 @@ class MockScreen: Identifiable { roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -591,12 +579,11 @@ class MockScreen: Identifiable { roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaPlayerProvider: MediaPlayerProviderMock(), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: .volatile()), linkMetadataProvider: LinkMetadataProvider(), completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()), ongoingCallRoomIDPublisher: .init(.init(nil)), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), analytics: analytics, composerDraftService: ComposerDraftServiceMock(.init()), @@ -610,7 +597,7 @@ class MockScreen: Identifiable { requestDelay: .seconds(5)) let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationControllerProxy, flow: .deviceInitiator, - appSettings: appSettings, + userSettings: .volatile(), mediaProvider: MediaProviderMock(.init())) return SessionVerificationScreenCoordinator(parameters: parameters) case .userSessionScreen, .userSessionScreenReply, .userSessionSpacesFlow: @@ -647,18 +634,19 @@ class MockScreen: Identifiable { let timelineControllerFactory = TimelineControllerFactoryMock(.init(timelineController: timelineController)) + let userSession = UserSessionMock(.init(clientProxy: clientProxy)) let flowCoordinator = UserSessionFlowCoordinator(isNewLogin: false, navigationRootCoordinator: navigationRootCoordinator, appLockService: AppLockService(keychainController: KeychainControllerMock(), appSettings: appSettings), - flowParameters: CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)), + flowParameters: CommonFlowParameters(userSession: userSession, bugReportService: BugReportServiceMock(.init()), elementCallService: ElementCallServiceMock(.init()), timelineControllerFactory: timelineControllerFactory, - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: userSession.userSettings), linkMetadataProvider: LinkMetadataProvider(), appMediator: appMediator, - appSettings: appSettings, + userSettings: userSession.userSettings, appHooks: AppHooks(), analytics: analytics, userIndicatorController: UserIndicatorControllerMock(), @@ -695,6 +683,7 @@ class MockScreen: Identifiable { clientProxy.createRoomNameTopicAccessTypeIsSpaceUserIDsAvatarURLAliasLocalPartReturnValue = .success("!new-room:client.com") clientProxy.roomForIdentifierClosure = { roomID in .joined(JoinedRoomProxyMock(.init(id: roomID, members: []))) } + let userSession = UserSessionMock(.init(clientProxy: clientProxy)) let userDiscoveryService = UserDiscoveryServiceMock() userDiscoveryService.searchProfilesWithReturnValue = .success([.mockBob, .mockBobby]) @@ -703,14 +692,14 @@ class MockScreen: Identifiable { let flowCoordinator = StartChatFlowCoordinator(entryPoint: .startChat, userDiscoveryService: userDiscoveryService, navigationStackCoordinator: navigationStackCoordinator, - flowParameters: CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)), + flowParameters: CommonFlowParameters(userSession: userSession, bugReportService: BugReportServiceMock(.init()), elementCallService: ElementCallServiceMock(.init()), timelineControllerFactory: TimelineControllerFactoryMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: userSession.userSettings), linkMetadataProvider: LinkMetadataProvider(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, + userSettings: userSession.userSettings, appHooks: AppHooks(), analytics: analytics, userIndicatorController: UserIndicatorControllerMock(), @@ -752,7 +741,6 @@ class MockScreen: Identifiable { navigationStackCoordinator.setRootCoordinator(BlankFormCoordinator()) let coordinator = EncryptionSettingsFlowCoordinator(parameters: .init(userSession: userSession, - appSettings: appSettings, appHooks: AppHooks(), userIndicatorController: UserIndicatorControllerMock(), navigationStackCoordinator: navigationStackCoordinator)) @@ -771,7 +759,6 @@ class MockScreen: Identifiable { let coordinator = EncryptionResetFlowCoordinator(parameters: .init(userSession: userSession, appMediator: AppMediatorMock(.init()), - appSettings: appSettings, appHooks: AppHooks(), userIndicatorController: userIndicatorController, navigationStackCoordinator: navigationStackCoordinator, @@ -787,6 +774,7 @@ class MockScreen: Identifiable { let clientProxy = ClientProxyMock(.init()) clientProxy.linkNewDeviceServiceReturnValue = linkNewDeviceService + let userSession = UserSessionMock(.init(clientProxy: clientProxy)) let keychainController = KeychainController(service: .tests, accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier) keychainController.resetSecrets() @@ -805,14 +793,14 @@ class MockScreen: Identifiable { let navigationStackCoordinator = NavigationStackCoordinator() let flowCoordinator = LinkNewDeviceFlowCoordinator(navigationStackCoordinator: navigationStackCoordinator, appLockService: appLockService, - flowParameters: CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)), + flowParameters: CommonFlowParameters(userSession: userSession, bugReportService: BugReportServiceMock(.init()), elementCallService: ElementCallServiceMock(.init()), timelineControllerFactory: TimelineControllerFactoryMock(.init()), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: userSession.userSettings), linkMetadataProvider: LinkMetadataProvider(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, + userSettings: userSession.userSettings, appHooks: AppHooks(), analytics: analytics, userIndicatorController: UserIndicatorControllerMock(), @@ -837,7 +825,7 @@ class MockScreen: Identifiable { navigationRootCoordinator.setSheetCoordinator(navigationStackCoordinator) return PlaceholderScreenCoordinator(hideBrandChrome: false) case .autoUpdatingTimeline: - let appSettings: AppSettings = appSettings + let userSettings = UserSettings.volatile() appSettings.hasRunIdentityConfirmationOnboarding = true appSettings.hasRunNotificationPermissionsOnboarding = true appSettings.analyticsConsentState = .optedOut @@ -845,6 +833,7 @@ class MockScreen: Identifiable { navigationRootCoordinator.setRootCoordinator(navigationSplitCoordinator) let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))))) + let userSession = UserSessionMock(.init(clientProxy: clientProxy, userSettings: userSettings)) let roomProxy = JoinedRoomProxyMock(.init(id: "whatever", name: "okay", shouldUseAutoUpdatingTimeline: true)) @@ -857,17 +846,17 @@ class MockScreen: Identifiable { attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), stateEventStringBuilder: RoomStateEventStringBuilder(userID: "@alice:matrix.org")), mediaProvider: MediaProviderMock(.init()), - appSettings: appSettings) + userSettings: userSettings) let flowCoordinator = ChatsTabFlowCoordinator(navigationSplitCoordinator: navigationSplitCoordinator, - flowParameters: CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)), + flowParameters: CommonFlowParameters(userSession: userSession, bugReportService: BugReportServiceMock(.init()), elementCallService: ElementCallServiceMock(.init()), timelineControllerFactory: TimelineControllerFactoryMock(.init(timelineController: timelineController)), - emojiProvider: EmojiProvider(appSettings: appSettings), + emojiProvider: EmojiProvider(userSettings: userSession.userSettings), linkMetadataProvider: LinkMetadataProvider(), appMediator: AppMediatorMock(.init()), - appSettings: appSettings, + userSettings: userSession.userSettings, appHooks: AppHooks(), analytics: analytics, userIndicatorController: UserIndicatorControllerMock(), @@ -915,6 +904,6 @@ class MockScreen: Identifiable { attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), stateEventStringBuilder: RoomStateEventStringBuilder(userID: "@alice:matrix.org")), mediaProvider: MediaProviderMock(.init()), - appSettings: appSettings) + userSettings: .volatile()) } } diff --git a/NSE/Sources/NSEUserSession.swift b/NSE/Sources/NSEUserSession.swift index b66f2a908..fac2dd94a 100644 --- a/NSE/Sources/NSEUserSession.swift +++ b/NSE/Sources/NSEUserSession.swift @@ -17,7 +17,7 @@ nonisolated protocol NSEUserSessionProtocol { } final nonisolated class NSEUserSession: NSEUserSessionProtocol { - private let appSettings: CommonSettingsProtocol + private let userSettings: CommonSettingsProtocol private let baseClient: ClientProtocol private let notificationClient: NotificationClient private let userID: String @@ -49,22 +49,22 @@ final nonisolated class NSEUserSession: NSEUserSessionProtocol { } var threadsEnabled: Bool { - appSettings.threadsEnabled + userSettings.threadsEnabled } init(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, clientFactory: ClientFactoryProtocol = ClientFactory(), - appSettings: CommonSettingsProtocol, + userSettings: CommonSettingsProtocol, appHooks: AppHooks) async throws { userID = credentials.userID - self.appSettings = appSettings + self.userSettings = userSettings baseClient = try await clientFactory.makeNSEClient(credentials: credentials, roomID: roomID, clientSessionDelegate: clientSessionDelegate, - appSettings: appSettings, + userSettings: userSettings, appHooks: appHooks) do { @@ -75,7 +75,7 @@ final nonisolated class NSEUserSession: NSEUserSessionProtocol { delegateHandle = try baseClient.setDelegate(delegate: ClientDelegateWrapper()) // Inject the content scanner so the SDK gates the media it downloads whilst building the notification. - if let contentScannerURL = appSettings.contentScannerURL.publisher.value { + if let contentScannerURL = userSettings.contentScannerURL.publisher.value { let contentScanner = ContentScanner(scannerUrl: contentScannerURL.absoluteString) await baseClient.setContentScanner(contentScanner: contentScanner) } diff --git a/NSE/Sources/NotificationServiceExtension.swift b/NSE/Sources/NotificationServiceExtension.swift index ec9febe9f..5f024bc2f 100644 --- a/NSE/Sources/NotificationServiceExtension.swift +++ b/NSE/Sources/NotificationServiceExtension.swift @@ -177,7 +177,7 @@ actor NotificationServiceExtensionActor { let userSession = try await NSEUserSession(credentials: credentials, roomID: roomID, clientSessionDelegate: keychainController, - appSettings: settings, + userSettings: settings, appHooks: appHooks) notificationHandler = NotificationHandler(userSession: userSession, diff --git a/ShareExtension/Sources/ShareExtensionViewController.swift b/ShareExtension/Sources/ShareExtensionViewController.swift index 7521a70f0..df30f5b72 100644 --- a/ShareExtension/Sources/ShareExtensionViewController.swift +++ b/ShareExtension/Sources/ShareExtensionViewController.swift @@ -12,7 +12,7 @@ import SwiftUI class ShareExtensionViewController: UIViewController { private static var targetConfiguration: Target.ConfigurationResult? - private let appSettings: CommonSettingsProtocol = { + private let userSettings: CommonSettingsProtocol = { guard let userDefaults = TrackedUserDefaults(suiteName: AppSettings.suiteName) else { fatalError("Catastrophic error retrieving user defaults for \(AppSettings.suiteName)") } @@ -33,10 +33,10 @@ class ShareExtensionViewController: UIViewController { appHooks.setUp() if Self.targetConfiguration == nil { - Self.targetConfiguration = Target.shareExtension.configure(logLevel: appSettings.logLevel, - traceLogPacks: appSettings.traceLogPacks, + Self.targetConfiguration = Target.shareExtension.configure(logLevel: userSettings.logLevel, + traceLogPacks: userSettings.traceLogPacks, sentryURL: nil, - rageshakeURL: appSettings.bugReportRageshakeURL, + rageshakeURL: userSettings.bugReportRageshakeURL, appHooks: appHooks) } @@ -50,7 +50,7 @@ class ShareExtensionViewController: UIViewController { if let credentials = keychainController.restorationTokens().first { let homeserverURL = credentials.restorationToken.session.homeserverUrl - appHooks.remoteSettingsHook.loadCache(forHomeserver: homeserverURL, applyingTo: appSettings) + appHooks.remoteSettingsHook.loadCache(forHomeserver: homeserverURL, applyingTo: userSettings) } else { // We should really show a different state when there isn't a logged in user, but for now this is fine. MXLog.error("Not logged in, launching app to show the authentication flow.")