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
This commit is contained in:
Doug
2026-09-25 13:51:33 +01:00
committed by Stefan Ceriu
parent 54cc1cba60
commit fccad5fc30
117 changed files with 554 additions and 594 deletions
+8
View File
@@ -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 = "<group>"; };
0FA60F848D1C14F873F9621A /* RoomMemberDetailsScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMemberDetailsScreenCoordinator.swift; sourceTree = "<group>"; };
0FD22AEFFA20065494ED2333 /* AppAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppAppearance.swift; sourceTree = "<group>"; };
100DA305FE28BB3B6AEDE1FD /* UserSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSettings.swift; sourceTree = "<group>"; };
104B7747499487538483FEAF /* SpacesScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpacesScreen.swift; sourceTree = "<group>"; };
105429F29096729EDD3152CF /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/SAS.strings; sourceTree = "<group>"; };
1059E2AE7878CF7820592637 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
@@ -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 */,
@@ -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,
@@ -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
@@ -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,
@@ -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()
}
@@ -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
@@ -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,
@@ -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)
}
}
@@ -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,
@@ -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 }
@@ -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()
@@ -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
@@ -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 }
@@ -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
@@ -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
@@ -64,7 +64,7 @@ extension ClientFactoryMock {
ClientSDKMock(.init(userID: credentials.userID))
}
makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksClosure = { credentials, _, _, _, _ in
makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksClosure = { credentials, _, _, _, _ in
ClientSDKMock(.init(userID: credentials.userID))
}
}
@@ -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 }
@@ -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
@@ -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")
@@ -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)
}
@@ -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
@@ -405,7 +405,7 @@ struct CallScreen_Previews: PreviewProvider {
voiceOnly: false,
colorScheme: .light),
allowPictureInPicture: false,
appSettings: .volatile(),
userSettings: .volatile(),
analyticsService: AnalyticsServiceMock(.init()))
}
}
@@ -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() {
@@ -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),
@@ -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)
}
}
@@ -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 {
@@ -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<String>.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<String>.makeStream().continuation)
static var previews: some View {
@@ -13,7 +13,7 @@ struct HomeScreenCoordinatorParameters {
let userSession: UserSessionProtocol
let bugReportService: BugReportServiceProtocol
let selectedRoomPublisher: CurrentValuePublisher<String?, Never>
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,
@@ -18,7 +18,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
private let spaceFilterSubject: CurrentValueSubject<SpaceServiceFilter?, Never>
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<String?, Never>,
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()
}
@@ -89,21 +89,21 @@ enum RoomListFilter: Int, CaseIterable, Identifiable {
struct RoomListFiltersState {
private(set) var activeFilters: OrderedSet<RoomListFilter>
private let appSettings: AppSettings
private let userSettings: UserSettings
init(activeFilters: OrderedSet<RoomListFilter> = [], appSettings: AppSettings) {
init(activeFilters: OrderedSet<RoomListFilter> = [], 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)
}
@@ -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)
@@ -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())))
}
}
@@ -234,7 +234,7 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
return HomeScreenViewModel(userSession: userSession,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: .volatile(),
userSettings: .volatile(),
analyticsService: AnalyticsServiceMock(.init()),
bugReportService: BugReportServiceMock(.init()),
notificationManager: NotificationManagerMock(),
@@ -145,7 +145,7 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview {
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([])))))))
return HomeScreenViewModel(userSession: userSession,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: .volatile(),
userSettings: .volatile(),
analyticsService: AnalyticsServiceMock(.init()),
bugReportService: BugReportServiceMock(.init()),
notificationManager: NotificationManagerMock(),
@@ -201,7 +201,7 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
return HomeScreenViewModel(userSession: userSession,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: .volatile(),
userSettings: .volatile(),
analyticsService: AnalyticsServiceMock(.init()),
bugReportService: BugReportServiceMock(.init()),
notificationManager: NotificationManagerMock(),
@@ -133,7 +133,7 @@ struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview {
return HomeScreenViewModel(userSession: userSession,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: .volatile(),
userSettings: .volatile(),
analyticsService: AnalyticsServiceMock(.init()),
bugReportService: BugReportServiceMock(.init()),
notificationManager: NotificationManagerMock(),
@@ -122,7 +122,7 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab
return HomeScreenViewModel(userSession: userSession,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: .volatile(),
userSettings: .volatile(),
analyticsService: AnalyticsServiceMock(.init()),
bugReportService: BugReportServiceMock(.init()),
notificationManager: NotificationManagerMock(),
@@ -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)
}
@@ -14,7 +14,7 @@ typealias JoinRoomScreenViewModelType = StateStoreViewModel<JoinRoomScreenViewSt
class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewModelProtocol {
private let source: JoinRoomScreenSource
private let appSettings: AppSettings
private let userSettings: UserSettings
private let clientProxy: ClientProxyProtocol
private let userIndicatorController: UserIndicatorControllerProtocol
@@ -30,11 +30,11 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
}
init(source: JoinRoomScreenSource,
appSettings: AppSettings,
userSettings: UserSettings,
userSession: UserSessionProtocol,
userIndicatorController: UserIndicatorControllerProtocol) {
self.source = source
self.appSettings = appSettings
self.userSettings = userSettings
clientProxy = userSession.clientProxy
self.userIndicatorController = userIndicatorController
@@ -52,7 +52,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
.sink { mode in
switch mode {
case .invited:
appSettings.seenInvites.insert(roomID)
userSettings.seenInvites.insert(roomID)
default:
break
}
@@ -350,7 +350,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
guard !hasSentJoinAction else { return }
let roomID = state.roomID
appSettings.seenInvites.remove(roomID)
userSettings.seenInvites.remove(roomID)
guard state.roomDetails?.isSpace == true else {
hasSentJoinAction = true
@@ -464,7 +464,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
return false
}
appSettings.seenInvites.remove(roomID)
userSettings.seenInvites.remove(roomID)
actionsSubject.send(.dismiss)
return true
@@ -402,7 +402,7 @@ struct JoinRoomScreenPreviewWrapper: Identifiable {
self.isSpace = isSpace
self.customPreviewName = customPreviewName
let appSettings = AppSettings.volatile()
let userSettings = UserSettings.volatile()
let clientProxy = ClientProxyMock(.init(hideInviteAvatars: hideInviteAvatars))
clientProxy.canJoinRoomWithReturnValue = canJoinRoom
@@ -455,7 +455,7 @@ struct JoinRoomScreenPreviewWrapper: Identifiable {
}
viewModel = JoinRoomScreenViewModel(source: source,
appSettings: appSettings,
userSettings: userSettings,
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
userIndicatorController: UserIndicatorControllerMock())
}
@@ -10,7 +10,7 @@ import Combine
import SwiftUI
struct LabsScreenCoordinatorParameters {
let appSettings: AppSettings
let userSettings: UserSettings
}
enum LabsScreenCoordinatorAction {
@@ -28,7 +28,7 @@ final class LabsScreenCoordinator: CoordinatorProtocol {
private var cancellables = Set<AnyCancellable>()
init(parameters: LabsScreenCoordinatorParameters) {
viewModel = LabsScreenViewModel(labsOptions: parameters.appSettings)
viewModel = LabsScreenViewModel(labsOptions: parameters.userSettings.app)
}
func start() {
@@ -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)
@@ -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()))
@@ -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,
@@ -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()))
}
@@ -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())
@@ -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)
}
}
@@ -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)
}
@@ -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 {
@@ -142,7 +142,7 @@ struct IdentityConfirmationScreen_Previews: PreviewProvider, TestablePreview {
userSession.sessionSecurityStatePublisher = CurrentValuePublisher<SessionSecurityState, Never>(.init(verificationState: .unverified, recoveryState: recoveryState))
return IdentityConfirmationScreenViewModel(userSession: userSession,
appSettings: .volatile(),
userSettings: .volatile(),
userIndicatorController: UserIndicatorControllerMock())
}
}
@@ -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)
}
@@ -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)
@@ -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)
@@ -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,
@@ -14,7 +14,7 @@ typealias PinnedEventsTimelineScreenViewModelType = StateStoreViewModel<PinnedEv
class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelType, PinnedEventsTimelineScreenViewModelProtocol {
private let roomProxy: JoinedRoomProxyProtocol
private let userIndicatorController: UserIndicatorControllerProtocol
private let appSettings: AppSettings
private let userSettings: UserSettings
private let analyticsService: AnalyticsServiceProtocol
private let actionsSubject: PassthroughSubject<PinnedEventsTimelineScreenViewModelAction, Never> = .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
@@ -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: [])
@@ -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()
@@ -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())
}
}
@@ -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,
@@ -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)
@@ -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(),
@@ -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
@@ -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()))
}
@@ -24,7 +24,6 @@ struct RoomScreenCoordinatorParameters {
let completionSuggestionService: CompletionSuggestionServiceProtocol
let ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never>
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<AnyCancellable>()
@@ -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)
@@ -17,7 +17,7 @@ typealias RoomScreenViewModelType = StateStoreViewModel<RoomScreenViewState, Roo
class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol {
private let clientProxy: ClientProxyProtocol
private let roomProxy: JoinedRoomProxyProtocol
private let appSettings: AppSettings
private let userSettings: UserSettings
private let analyticsService: AnalyticsServiceProtocol
private let userIndicatorController: UserIndicatorControllerProtocol
@@ -54,13 +54,12 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
roomProxy: JoinedRoomProxyProtocol,
initialSelectedPinnedEventID: String?,
ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never>,
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<String?, Never>) {
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())
@@ -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()))
@@ -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() {
@@ -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<Void, Never>?
private var searchModeObservationTask: Task<Void, Never>?
private var loadingObservationTask: Task<Void, Never>?
@@ -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) {
@@ -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 {
@@ -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() {
@@ -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() {
@@ -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<SecurityAndPrivacyScreenViewModelAction, Never> = .init()
var actionsPublisher: AnyPublisher<SecurityAndPrivacyScreenViewModelAction, Never> {
@@ -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() {
@@ -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 {
@@ -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
@@ -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)
@@ -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) }
@@ -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 {
@@ -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)
}
@@ -14,16 +14,16 @@ typealias AnalyticsSettingsScreenViewModelType = StateStoreViewModelV2<Analytics
class AnalyticsSettingsScreenViewModel: AnalyticsSettingsScreenViewModelType, AnalyticsSettingsScreenViewModelProtocol {
private let analytics: AnalyticsServiceProtocol
init(appSettings: AppSettings, analytics: AnalyticsServiceProtocol) {
init(userSettings: UserSettings, analytics: AnalyticsServiceProtocol) {
self.analytics = analytics
let strings = AnalyticsSettingsScreenStrings(termsURL: appSettings.analyticsTermsURL)
let strings = AnalyticsSettingsScreenStrings(termsURL: userSettings.analyticsTermsURL)
let bindings = AnalyticsSettingsScreenViewStateBindings(enableAnalytics: analytics.isEnabled)
let state = AnalyticsSettingsScreenViewState(strings: strings, bindings: bindings)
super.init(initialViewState: state)
appSettings.analyticsConsentStatePublisher
userSettings.analyticsConsentStatePublisher
.map { $0 == .optedIn }
.weakAssign(to: \.state.bindings.enableAnalytics, on: self)
.store(in: &cancellables)
@@ -39,8 +39,8 @@ struct AnalyticsSettingsScreen: View {
struct AnalyticsSettingsScreen_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
let appSettings = AppSettings.volatile()
let viewModel = AnalyticsSettingsScreenViewModel(appSettings: appSettings,
let userSettings = UserSettings.volatile()
let viewModel = AnalyticsSettingsScreenViewModel(userSettings: userSettings,
analytics: AnalyticsServiceMock(.init()))
AnalyticsSettingsScreen(context: viewModel.context)
}
@@ -12,8 +12,8 @@ import SwiftUI
final class LegalInformationScreenCoordinator: CoordinatorProtocol {
private let viewModel: LegalInformationScreenViewModelProtocol
init(appSettings: AppSettings) {
viewModel = LegalInformationScreenViewModel(appSettings: appSettings)
init(userSettings: UserSettings) {
viewModel = LegalInformationScreenViewModel(userSettings: userSettings)
}
func toPresentable() -> AnyView {
@@ -12,9 +12,9 @@ import SwiftUI
typealias LegalInformationScreenViewModelType = StateStoreViewModelV2<LegalInformationScreenViewState, LegalInformationScreenViewAction>
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))
}
}
@@ -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)
}
@@ -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)
@@ -13,7 +13,7 @@ typealias NotificationSettingsScreenViewModelType = StateStoreViewModelV2<Notifi
class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelType, NotificationSettingsScreenViewModelProtocol {
private var actionsSubject: PassthroughSubject<NotificationSettingsScreenViewModelAction, Never> = .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)")
@@ -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,
@@ -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)
@@ -12,7 +12,7 @@ import SwiftUI
typealias SettingsScreenViewModelType = StateStoreViewModelV2<SettingsScreenViewState, SettingsScreenViewAction>
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:
@@ -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())
@@ -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())
}
}
@@ -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(),
@@ -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])
@@ -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<AnyCancellable>()
@@ -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)
@@ -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,
@@ -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()))
}
@@ -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 {
@@ -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()))
}()
@@ -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"]
@@ -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"),
@@ -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 {

Some files were not shown because too many files have changed in this diff Show More