mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Remove the CommonSettingsProtocol and use UserSession to carry multiple dependencies. (#6302)
* Remove the CommonSettingsProtocol. * Replace multiple dependencies with the UserSession when it carries them.
This commit is contained in:
@@ -15,11 +15,11 @@ enum RemoteSettingsError: Error {
|
||||
|
||||
protocol RemoteSettingsHookProtocol: Sendable {
|
||||
#if IS_MAIN_APP
|
||||
@MainActor func initializeCache(using client: ClientProtocol, applyingTo appSettings: CommonSettingsProtocol) async -> Result<Void, RemoteSettingsError>
|
||||
@MainActor func initializeCache(using client: ClientProtocol, applyingTo appSettings: AppSettings) async -> Result<Void, RemoteSettingsError>
|
||||
func updateCache(using client: ClientProtocol) async
|
||||
@MainActor func reset(_ appSettings: CommonSettingsProtocol)
|
||||
@MainActor func reset(_ appSettings: AppSettings)
|
||||
#endif
|
||||
@MainActor func loadCache(forHomeserver homeserver: String, applyingTo appSettings: CommonSettingsProtocol)
|
||||
@MainActor func loadCache(forHomeserver homeserver: String, applyingTo appSettings: AppSettings)
|
||||
}
|
||||
|
||||
struct DefaultRemoteSettingsHook: RemoteSettingsHookProtocol {
|
||||
@@ -27,7 +27,7 @@ struct DefaultRemoteSettingsHook: RemoteSettingsHookProtocol {
|
||||
/// A best effort implementation to let Element X advertise to users when they should be using
|
||||
/// Element Pro. In an ideal world the backend would be able to validate the client's requests
|
||||
/// instead of relying on it to check a well-known file for this.
|
||||
func initializeCache(using client: ClientProtocol, applyingTo appSettings: CommonSettingsProtocol) async -> Result<Void, RemoteSettingsError> {
|
||||
func initializeCache(using client: ClientProtocol, applyingTo appSettings: AppSettings) async -> Result<Void, RemoteSettingsError> {
|
||||
guard case let .success(wellKnownData) = await client.elementWellKnown() else {
|
||||
// Nothing to check, carry on as normal.
|
||||
return .success(())
|
||||
@@ -49,10 +49,10 @@ struct DefaultRemoteSettingsHook: RemoteSettingsHookProtocol {
|
||||
}
|
||||
|
||||
func updateCache(using client: ClientProtocol) async { }
|
||||
func reset(_ appSettings: any CommonSettingsProtocol) { }
|
||||
func reset(_ appSettings: AppSettings) { }
|
||||
#endif
|
||||
|
||||
func loadCache(forHomeserver homeserver: String, applyingTo appSettings: CommonSettingsProtocol) { }
|
||||
func loadCache(forHomeserver homeserver: String, applyingTo appSettings: AppSettings) { }
|
||||
}
|
||||
|
||||
private struct ElementWellKnown: Decodable {
|
||||
|
||||
@@ -799,7 +799,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: appMediator,
|
||||
userSettings: userSession.userSettings, // TODO: @pixlwave Remove this in favour of the userSession.
|
||||
appHooks: appHooks,
|
||||
analytics: analyticsService,
|
||||
userIndicatorController: userIndicatorController,
|
||||
|
||||
@@ -31,7 +31,6 @@ struct CommonFlowParameters {
|
||||
let emojiProvider: EmojiProviderProtocol
|
||||
let linkMetadataProvider: LinkMetadataProviderProtocol
|
||||
let appMediator: AppMediatorProtocol
|
||||
let userSettings: UserSettings
|
||||
let appHooks: AppHooks
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
@@ -15,24 +15,6 @@ import Foundation
|
||||
import Macros
|
||||
import SwiftUI
|
||||
|
||||
/// Common settings between app and NSE
|
||||
nonisolated protocol CommonSettingsProtocol: AnyObject, Sendable {
|
||||
var lastNotificationBootTime: TimeInterval? { get set }
|
||||
var selectedNotificationTone: NotificationTone? { get set }
|
||||
var lastKnownBadgeCount: Int { get set }
|
||||
|
||||
var logLevel: LogLevel { get }
|
||||
var traceLogPacks: Set<TraceLogPack> { get }
|
||||
var bugReportRageshakeURL: RemotePreference<RageshakeConfiguration> { get }
|
||||
var contentScannerURL: RemotePreference<URL?> { get }
|
||||
var forceDisableE2EE: RemotePreference<Bool> { get }
|
||||
var mapTilerConfiguration: RemotePreference<MapTilerConfiguration> { get }
|
||||
|
||||
var enableOnlySignedDeviceIsolationMode: Bool { get }
|
||||
var threadsEnabled: Bool { get }
|
||||
var hideQuietNotificationAlerts: Bool { get }
|
||||
}
|
||||
|
||||
nonisolated enum AppBuildType {
|
||||
case debug
|
||||
case nightly
|
||||
@@ -475,5 +457,3 @@ final nonisolated class AppSettings: @unchecked Sendable {
|
||||
AppSettings(store: VolatileUserDefaults())
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated extension AppSettings: CommonSettingsProtocol { }
|
||||
|
||||
@@ -377,7 +377,6 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let parameters = HomeScreenCoordinatorParameters(userSession: userSession,
|
||||
bugReportService: flowParameters.bugReportService,
|
||||
selectedRoomPublisher: selectedRoomSubject.asCurrentValuePublisher(),
|
||||
userSettings: flowParameters.userSettings,
|
||||
analyticsService: flowParameters.analytics,
|
||||
notificationManager: flowParameters.notificationManager,
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
|
||||
@@ -84,7 +84,6 @@ class MediaEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
|
||||
userSession: userSession,
|
||||
mediaPlayerProvider: MediaPlayerProvider(),
|
||||
appMediator: flowParameters.appMediator,
|
||||
userSettings: flowParameters.userSettings,
|
||||
analytics: flowParameters.analytics,
|
||||
emojiProvider: flowParameters.emojiProvider,
|
||||
linkMetadataProvider: flowParameters.linkMetadataProvider,
|
||||
|
||||
@@ -69,7 +69,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
||||
self.appLockService = appLockService
|
||||
analyticsService = flowParameters.analytics
|
||||
appMediator = flowParameters.appMediator
|
||||
userSettings = flowParameters.userSettings
|
||||
userSettings = flowParameters.userSession.userSettings
|
||||
appHooks = flowParameters.appHooks
|
||||
notificationManager = flowParameters.notificationManager
|
||||
userIndicatorController = flowParameters.userIndicatorController
|
||||
@@ -281,8 +281,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController,
|
||||
flow: .deviceInitiator,
|
||||
userSettings: userSettings,
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
userSession: userSession)
|
||||
|
||||
let coordinator = SessionVerificationScreenCoordinator(parameters: parameters)
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
|
||||
userSession: userSession,
|
||||
mediaPlayerProvider: MediaPlayerProvider(),
|
||||
appMediator: flowParameters.appMediator,
|
||||
userSettings: flowParameters.userSettings,
|
||||
analytics: flowParameters.analytics,
|
||||
emojiProvider: flowParameters.emojiProvider,
|
||||
linkMetadataProvider: flowParameters.linkMetadataProvider,
|
||||
@@ -107,15 +106,13 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let params = LocationSharingScreenCoordinatorParameters(interactionMode: interactionMode,
|
||||
mapURLBuilder: flowParameters.userSettings.app.mapTilerConfiguration.publisher.value,
|
||||
mapURLBuilder: userSession.userSettings.app.mapTilerConfiguration.publisher.value,
|
||||
roomProxy: roomProxy,
|
||||
timelineController: timelineController,
|
||||
liveLocationManager: flowParameters.userSession.liveLocationManager,
|
||||
userSettings: flowParameters.userSettings,
|
||||
userSession: userSession,
|
||||
appMediator: flowParameters.appMediator,
|
||||
analytics: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
mediaProvider: flowParameters.userSession.mediaProvider)
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = LocationSharingScreenCoordinator(parameters: params)
|
||||
|
||||
coordinator.actions.sink { [weak self] action in
|
||||
|
||||
@@ -238,7 +238,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
defer { hideLoadingIndicator() }
|
||||
switch await roomProxy.loadOrFetchEventDetails(for: eventID) {
|
||||
case .success(let event):
|
||||
if flowParameters.userSettings.app.threadsEnabled, let threadRootEventID = event.threadRootEventId() {
|
||||
if userSession.userSettings.app.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.userSettings.app.threadsEnabled, let threadRootEventID = event.threadRootEventId() {
|
||||
if userSession.userSettings.app.threadsEnabled, let threadRootEventID = event.threadRootEventId() {
|
||||
stateMachine.tryEvent(.presentRoom(presentationAction: .thread(rootEventID: threadRootEventID,
|
||||
focusEvent: .init(eventID: focusEvent.eventID,
|
||||
shouldSetPin: focusEvent.shouldSetPin))),
|
||||
@@ -798,7 +798,6 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
linkMetadataProvider: flowParameters.linkMetadataProvider,
|
||||
completionSuggestionService: completionSuggestionService,
|
||||
appMediator: flowParameters.appMediator,
|
||||
userSettings: flowParameters.userSettings,
|
||||
analytics: flowParameters.analytics,
|
||||
composerDraftService: composerDraftService,
|
||||
timelineControllerFactory: flowParameters.timelineControllerFactory,
|
||||
@@ -855,8 +854,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentJoinRoomScreen(via: [String], animated: Bool) {
|
||||
let coordinator = JoinRoomScreenCoordinator(parameters: .init(source: .generic(roomID: roomID, via: via),
|
||||
userSession: userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
userSettings: flowParameters.userSettings))
|
||||
userIndicatorController: flowParameters.userIndicatorController))
|
||||
|
||||
joinRoomScreenCoordinator = coordinator
|
||||
|
||||
@@ -939,7 +937,6 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentRoomDetails(isRoot: Bool, animated: Bool) async {
|
||||
let params = RoomDetailsScreenCoordinatorParameters(roomProxy: roomProxy,
|
||||
userSession: userSession,
|
||||
userSettings: flowParameters.userSettings,
|
||||
appHooks: flowParameters.appHooks,
|
||||
analyticsService: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
@@ -1019,7 +1016,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
let roomDetailsEditParameters = RoomDetailsEditScreenCoordinatorParameters(roomProxy: roomProxy,
|
||||
userSession: userSession,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSettings),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: userSession.userSettings),
|
||||
navigationStackCoordinator: stackCoordinator,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
orientationManager: flowParameters.appMediator.windowManager)
|
||||
@@ -1119,9 +1116,9 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let parameters = MediaUploadPreviewScreenCoordinatorParameters(mediaURLs: mediaURLs,
|
||||
caption: caption,
|
||||
title: title,
|
||||
shouldShowCaptionWarning: flowParameters.userSettings.app.shouldShowMediaCaptionWarning,
|
||||
galleryEnabled: flowParameters.userSettings.app.galleryEnabled,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSettings),
|
||||
shouldShowCaptionWarning: userSession.userSettings.app.shouldShowMediaCaptionWarning,
|
||||
galleryEnabled: userSession.userSettings.app.galleryEnabled,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: userSession.userSettings),
|
||||
timelineController: timelineController,
|
||||
clientProxy: userSession.clientProxy,
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
@@ -1176,15 +1173,13 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let params = LocationSharingScreenCoordinatorParameters(interactionMode: interactionMode,
|
||||
mapURLBuilder: flowParameters.userSettings.app.mapTilerConfiguration.publisher.value,
|
||||
mapURLBuilder: userSession.userSettings.app.mapTilerConfiguration.publisher.value,
|
||||
roomProxy: roomProxy,
|
||||
timelineController: timelineController,
|
||||
liveLocationManager: flowParameters.userSession.liveLocationManager,
|
||||
userSettings: flowParameters.userSettings,
|
||||
userSession: userSession,
|
||||
appMediator: flowParameters.appMediator,
|
||||
analytics: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
mediaProvider: flowParameters.userSession.mediaProvider)
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = LocationSharingScreenCoordinator(parameters: params)
|
||||
|
||||
coordinator.actions.sink { [weak self] action in
|
||||
@@ -1324,8 +1319,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
userSession: userSession,
|
||||
userNotificationCenter: UNUserNotificationCenter.current(),
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
isModallyPresented: true,
|
||||
userSettings: flowParameters.userSettings)
|
||||
isModallyPresented: true)
|
||||
let coordinator = NotificationSettingsScreenCoordinator(parameters: parameters)
|
||||
coordinator.actions.sink { [weak self] action in
|
||||
switch action {
|
||||
@@ -1418,9 +1412,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private func presentSecurityAndPrivacyScreen() {
|
||||
let coordinator = SecurityAndPrivacyScreenCoordinator(parameters: .init(roomProxy: roomProxy,
|
||||
clientProxy: userSession.clientProxy,
|
||||
userSession: userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
appSetting: flowParameters.userSettings,
|
||||
appHooks: flowParameters.appHooks))
|
||||
|
||||
coordinator.actionsPublisher.sink { [weak self] action in
|
||||
|
||||
@@ -23,6 +23,10 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private let navigationStackCoordinator: NavigationStackCoordinator
|
||||
private let flowParameters: CommonFlowParameters
|
||||
|
||||
private var userSettings: UserSettings {
|
||||
flowParameters.userSession.userSettings
|
||||
}
|
||||
|
||||
// periphery:ignore - retaining purpose
|
||||
private var appLockSetupFlowCoordinator: AppLockSetupFlowCoordinator?
|
||||
private var bugReportFlowCoordinator: BugReportFlowCoordinator?
|
||||
@@ -73,7 +77,6 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private func presentSettingsScreen(animated: Bool) {
|
||||
let settingsScreenCoordinator = SettingsScreenCoordinator(parameters: .init(userSession: flowParameters.userSession,
|
||||
userSettings: flowParameters.userSettings,
|
||||
isBugReportServiceEnabled: flowParameters.bugReportService.isEnabled,
|
||||
isInSecondaryWindow: isInSecondaryWindow,
|
||||
userIndicatorController: flowParameters.userIndicatorController))
|
||||
@@ -139,7 +142,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
private func presentLabs() {
|
||||
let coordinator = LabsScreenCoordinator(parameters: .init(userSettings: flowParameters.userSettings))
|
||||
let coordinator = LabsScreenCoordinator(parameters: .init(userSettings: userSettings))
|
||||
coordinator.actions
|
||||
.sink { [weak self] action in
|
||||
switch action {
|
||||
@@ -190,7 +193,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentUserDetailsEditScreen() {
|
||||
let coordinator = UserDetailsEditScreenCoordinator(parameters: .init(orientationManager: flowParameters.windowManager,
|
||||
userSession: flowParameters.userSession,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSettings),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: userSettings),
|
||||
navigationStackCoordinator: navigationStackCoordinator,
|
||||
userIndicatorController: flowParameters.userIndicatorController))
|
||||
coordinator.actions
|
||||
@@ -234,7 +237,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
private func presentAnalyticsScreen() {
|
||||
let coordinator = AnalyticsSettingsScreenCoordinator(parameters: .init(userSettings: flowParameters.userSettings,
|
||||
let coordinator = AnalyticsSettingsScreenCoordinator(parameters: .init(userSettings: userSettings,
|
||||
analytics: flowParameters.analytics))
|
||||
navigationStackCoordinator.push(coordinator)
|
||||
}
|
||||
@@ -260,11 +263,11 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
private func presentLegalInformationScreen() {
|
||||
navigationStackCoordinator.push(LegalInformationScreenCoordinator(userSettings: flowParameters.userSettings))
|
||||
navigationStackCoordinator.push(LegalInformationScreenCoordinator(userSettings: userSettings))
|
||||
}
|
||||
|
||||
private func presentBlockedUsersScreen() {
|
||||
let coordinator = BlockedUsersScreenCoordinator(parameters: .init(hideProfiles: flowParameters.userSettings.app.hideIgnoredUserProfiles,
|
||||
let coordinator = BlockedUsersScreenCoordinator(parameters: .init(hideProfiles: userSettings.app.hideIgnoredUserProfiles,
|
||||
userSession: flowParameters.userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController))
|
||||
navigationStackCoordinator.push(coordinator)
|
||||
@@ -275,8 +278,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
userSession: flowParameters.userSession,
|
||||
userNotificationCenter: UNUserNotificationCenter.current(),
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
isModallyPresented: false,
|
||||
userSettings: flowParameters.userSettings)
|
||||
isModallyPresented: false)
|
||||
let coordinator = NotificationSettingsScreenCoordinator(parameters: notificationParameters)
|
||||
navigationStackCoordinator.push(coordinator)
|
||||
}
|
||||
@@ -300,20 +302,20 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
|
||||
private func presentMediaUploadQualitySettings() {
|
||||
let parameters = MediaUploadQualitySettingsScreenCoordinatorParameters(userSettings: flowParameters.userSettings,
|
||||
let parameters = MediaUploadQualitySettingsScreenCoordinatorParameters(userSettings: userSettings,
|
||||
analytics: flowParameters.analytics)
|
||||
let coordinator = MediaUploadQualitySettingsScreenCoordinator(parameters: parameters)
|
||||
navigationStackCoordinator.push(coordinator)
|
||||
}
|
||||
|
||||
private func presentLocationSharingSettings() {
|
||||
let parameters = LocationSharingSettingsScreenCoordinatorParameters(userSettings: flowParameters.userSettings)
|
||||
let parameters = LocationSharingSettingsScreenCoordinatorParameters(userSettings: userSettings)
|
||||
let coordinator = LocationSharingSettingsScreenCoordinator(parameters: parameters)
|
||||
navigationStackCoordinator.push(coordinator)
|
||||
}
|
||||
|
||||
private func presentDeveloperOptions() {
|
||||
let coordinator = DeveloperOptionsScreenCoordinator(appSettings: flowParameters.userSettings.app,
|
||||
let coordinator = DeveloperOptionsScreenCoordinator(appSettings: userSettings.app,
|
||||
appHooks: flowParameters.appHooks,
|
||||
clientProxy: flowParameters.userSession.clientProxy)
|
||||
|
||||
@@ -359,7 +361,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
accountSettingsPresenter = OAuthAccountSettingsPresenter(accountURL: url,
|
||||
presentationAnchor: flowParameters.windowManager.mainWindow,
|
||||
appMediator: flowParameters.appMediator,
|
||||
userSettings: flowParameters.userSettings,
|
||||
userSettings: userSettings,
|
||||
appHooks: flowParameters.appHooks,
|
||||
continuation: continuation)
|
||||
accountSettingsPresenter?.start()
|
||||
|
||||
@@ -399,8 +399,7 @@ class SpaceFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
let parameters = JoinRoomScreenCoordinatorParameters(source: .space(spaceServiceRoom),
|
||||
userSession: flowParameters.userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
userSettings: flowParameters.userSettings)
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = JoinRoomScreenCoordinator(parameters: parameters)
|
||||
coordinator.actionsPublisher
|
||||
.sink { [weak self] action in
|
||||
|
||||
@@ -211,7 +211,6 @@ final class SpaceSettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentSpaceSettings(animated: Bool) {
|
||||
let coordinator = RoomDetailsScreenCoordinator(parameters: .init(roomProxy: roomProxy,
|
||||
userSession: flowParameters.userSession,
|
||||
userSettings: flowParameters.userSettings,
|
||||
appHooks: flowParameters.appHooks,
|
||||
analyticsService: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
@@ -252,7 +251,7 @@ final class SpaceSettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
let parameters = RoomDetailsEditScreenCoordinatorParameters(roomProxy: roomProxy,
|
||||
userSession: flowParameters.userSession,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSettings),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: flowParameters.userSession.userSettings),
|
||||
navigationStackCoordinator: stackCoordinator,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
orientationManager: flowParameters.appMediator.windowManager)
|
||||
@@ -276,9 +275,8 @@ final class SpaceSettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private func presentSecurityAndPrivacyScreen() {
|
||||
let coordinator = SecurityAndPrivacyScreenCoordinator(parameters: .init(roomProxy: roomProxy,
|
||||
clientProxy: flowParameters.userSession.clientProxy,
|
||||
userSession: flowParameters.userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
appSetting: flowParameters.userSettings,
|
||||
appHooks: flowParameters.appHooks))
|
||||
|
||||
coordinator.actionsPublisher.sink { [weak self] action in
|
||||
|
||||
@@ -214,7 +214,6 @@ class StartChatFlowCoordinator: FlowCoordinatorProtocol {
|
||||
shouldShowCancelButton: isRoot,
|
||||
userSession: flowParameters.userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
userSettings: flowParameters.userSettings,
|
||||
analytics: flowParameters.analytics,
|
||||
appHooks: flowParameters.appHooks)
|
||||
let coordinator = CreateRoomScreenCoordinator(parameters: createParameters)
|
||||
|
||||
@@ -82,29 +82,27 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
self.appLockService = appLockService
|
||||
self.flowParameters = flowParameters
|
||||
presenceService = PresenceService(clientProxy: flowParameters.userSession.clientProxy,
|
||||
userSettings: flowParameters.userSettings)
|
||||
userSettings: flowParameters.userSession.userSettings)
|
||||
|
||||
navigationTabCoordinator = NavigationTabCoordinator()
|
||||
navigationRootCoordinator.setRootCoordinator(navigationTabCoordinator)
|
||||
|
||||
let chatsSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.userSettings.app.hideBrandChrome))
|
||||
let chatsSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.userSession.userSettings.app.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.userSettings.app.hideBrandChrome))
|
||||
let spacesSplitCoordinator = NavigationSplitCoordinator(placeholderCoordinator: PlaceholderScreenCoordinator(hideBrandChrome: flowParameters.userSession.userSettings.app.hideBrandChrome))
|
||||
spacesTabFlowCoordinator = SpacesTabFlowCoordinator(navigationSplitCoordinator: spacesSplitCoordinator,
|
||||
flowParameters: flowParameters)
|
||||
spacesTabDetails = .init(tag: HomeTab.spaces, title: L10n.screenHomeTabSpaces, icon: \.space, selectedIcon: \.spaceSolid)
|
||||
spacesTabDetails.navigationSplitCoordinator = spacesSplitCoordinator
|
||||
|
||||
if flowParameters.userSettings.app.globalSearchEnabled, #available(iOS 26.0, *) {
|
||||
if flowParameters.userSession.userSettings.app.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,
|
||||
userSettings: flowParameters.userSettings))
|
||||
userSession: flowParameters.userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController))
|
||||
let searchStackCoordinator = NavigationStackCoordinator()
|
||||
searchStackCoordinator.setRootCoordinator(searchCoordinator)
|
||||
|
||||
@@ -426,8 +424,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController,
|
||||
flow: flow,
|
||||
userSettings: flowParameters.userSettings,
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
userSession: userSession)
|
||||
|
||||
let coordinator = SessionVerificationScreenCoordinator(parameters: parameters)
|
||||
|
||||
@@ -464,8 +461,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
presentCallScreen(configuration: .init(roomProxy: roomProxy,
|
||||
clientProxy: userSession.clientProxy,
|
||||
clientID: InfoPlistReader.main.bundleIdentifier,
|
||||
elementCallBaseURL: flowParameters.userSettings.app.elementCallBaseURL,
|
||||
elementCallBaseURLOverride: flowParameters.userSettings.app.elementCallBaseURLOverride,
|
||||
elementCallBaseURL: userSession.userSettings.app.elementCallBaseURL,
|
||||
elementCallBaseURLOverride: userSession.userSettings.app.elementCallBaseURLOverride,
|
||||
voiceOnly: voiceOnly,
|
||||
colorScheme: colorScheme))
|
||||
}
|
||||
@@ -487,7 +484,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let callScreenCoordinator = CallScreenCoordinator(parameters: .init(elementCallService: flowParameters.elementCallService,
|
||||
configuration: configuration,
|
||||
allowPictureInPicture: true,
|
||||
userSettings: flowParameters.userSettings,
|
||||
userSettings: userSession.userSettings,
|
||||
analytics: flowParameters.analytics))
|
||||
|
||||
callScreenCoordinator.actions
|
||||
|
||||
@@ -2357,14 +2357,14 @@ nonisolated class ClientFactoryMock: ClientFactoryProtocol, @unchecked Sendable
|
||||
return makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksCallsCount > 0
|
||||
}
|
||||
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)? {
|
||||
private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedArguments: (credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: UserSettings, appHooks: AppHooks)?
|
||||
var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedArguments: (credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: UserSettings, appHooks: AppHooks)? {
|
||||
get { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedArgumentsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedArguments } }
|
||||
set { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedArgumentsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedArguments = 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)] {
|
||||
private nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedInvocations: [(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: UserSettings, appHooks: AppHooks)] = []
|
||||
var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedInvocations: [(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: UserSettings, appHooks: AppHooks)] {
|
||||
get { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedInvocationsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedInvocations } }
|
||||
set { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReceivedInvocationsLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReceivedInvocations = newValue } }
|
||||
}
|
||||
@@ -2375,9 +2375,9 @@ nonisolated class ClientFactoryMock: ClientFactoryProtocol, @unchecked Sendable
|
||||
get { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReturnValueLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReturnValue } }
|
||||
set { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksReturnValueLock.withLock { makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksUnderlyingReturnValue = newValue } }
|
||||
}
|
||||
nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksClosure: ((KeychainCredentials, String, ClientSessionDelegate, CommonSettingsProtocol, AppHooks) async throws -> ClientProtocol)?
|
||||
nonisolated(unsafe) var makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksClosure: ((KeychainCredentials, String, ClientSessionDelegate, UserSettings, AppHooks) async throws -> ClientProtocol)?
|
||||
|
||||
@concurrent func makeNSEClient(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: CommonSettingsProtocol, appHooks: AppHooks) async throws -> ClientProtocol {
|
||||
@concurrent func makeNSEClient(credentials: KeychainCredentials, roomID: String, clientSessionDelegate: ClientSessionDelegate, userSettings: UserSettings, appHooks: AppHooks) async throws -> ClientProtocol {
|
||||
if let error = makeNSEClientCredentialsRoomIDClientSessionDelegateUserSettingsAppHooksThrowableError {
|
||||
throw error
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ struct UserSessionMockConfiguration {
|
||||
var clientProxy: ClientProxyProtocol = ClientProxyMock(.init())
|
||||
var userSettings: UserSettings = .mock()
|
||||
var contentScannerService: ContentScannerServiceProtocol?
|
||||
var liveLocationManager: LiveLocationManagerProtocol = LiveLocationManagerMock(.init())
|
||||
}
|
||||
|
||||
@MainActor extension UserSessionMock {
|
||||
@@ -28,6 +29,6 @@ struct UserSessionMockConfiguration {
|
||||
|
||||
sessionSecurityStatePublisher = CurrentValueSubject<SessionSecurityState, Never>(.init(verificationState: .verified, recoveryState: .enabled)).asCurrentValuePublisher()
|
||||
|
||||
liveLocationManager = LiveLocationManagerMock(.init())
|
||||
liveLocationManager = configuration.liveLocationManager
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ struct CreateRoomScreenCoordinatorParameters {
|
||||
let shouldShowCancelButton: Bool
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let appHooks: AppHooks
|
||||
}
|
||||
@@ -42,7 +41,6 @@ final class CreateRoomScreenCoordinator: CoordinatorProtocol {
|
||||
userSession: parameters.userSession,
|
||||
analytics: parameters.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
userSettings: parameters.userSettings,
|
||||
appHooks: parameters.appHooks)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,9 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen
|
||||
userSession: UserSessionProtocol,
|
||||
analytics: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
userSettings: UserSettings,
|
||||
appHooks: AppHooks) {
|
||||
self.userSession = userSession
|
||||
mediaUploadingPreprocessor = MediaUploadingPreprocessor(userSettings: userSettings)
|
||||
mediaUploadingPreprocessor = MediaUploadingPreprocessor(userSettings: userSession.userSettings)
|
||||
self.analytics = analytics
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
@@ -64,7 +63,7 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen
|
||||
shouldShowCancelButton: shouldShowCancelButton,
|
||||
roomName: "",
|
||||
serverName: userSession.clientProxy.userIDServerName ?? "",
|
||||
isKnockingFeatureEnabled: userSettings.app.knockingEnabled,
|
||||
isKnockingFeatureEnabled: userSession.userSettings.app.knockingEnabled,
|
||||
canSelectSpace: canSelectSpace,
|
||||
aliasLocalPart: roomAliasNameFromRoomDisplayName(roomName: ""),
|
||||
bindings: bindings)
|
||||
|
||||
@@ -459,7 +459,7 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy.isAliasAvailableReturnValue = .success(isAliasAvailable)
|
||||
let spaces = [SpaceServiceRoom].mockJoinedSpaces2
|
||||
clientProxy.spaceService = SpaceServiceProxyMock(.init(editableSpaces: spaces))
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy, userSettings: userSettings))
|
||||
|
||||
return CreateRoomScreenViewModel(isSpace: isSpace,
|
||||
spaceSelectionMode: selectionMode,
|
||||
@@ -467,7 +467,6 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview {
|
||||
userSession: userSession,
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: userSettings,
|
||||
appHooks: AppHooks())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,15 +65,12 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview
|
||||
clientProxy.spaceService = SpaceServiceProxyMock(.init(editableSpaces: .mockJoinedSpaces2))
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
let userSettings = UserSettings.mock()
|
||||
|
||||
return CreateRoomScreenViewModel(isSpace: false,
|
||||
spaceSelectionMode: .editableSpacesList(preSelectedSpace: nil),
|
||||
shouldShowCancelButton: false,
|
||||
userSession: userSession,
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: userSettings,
|
||||
appHooks: AppHooks())
|
||||
}()
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ struct HomeScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let bugReportService: BugReportServiceProtocol
|
||||
let selectedRoomPublisher: CurrentValuePublisher<String?, Never>
|
||||
let userSettings: UserSettings
|
||||
let analyticsService: AnalyticsServiceProtocol
|
||||
let notificationManager: NotificationManagerProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -50,7 +49,6 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: HomeScreenCoordinatorParameters) {
|
||||
viewModel = HomeScreenViewModel(userSession: parameters.userSession,
|
||||
selectedRoomPublisher: parameters.selectedRoomPublisher,
|
||||
userSettings: parameters.userSettings,
|
||||
analyticsService: parameters.analyticsService,
|
||||
bugReportService: parameters.bugReportService,
|
||||
notificationManager: parameters.notificationManager,
|
||||
|
||||
@@ -32,7 +32,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
// swiftlint:disable:next function_body_length
|
||||
init(userSession: UserSessionProtocol,
|
||||
selectedRoomPublisher: CurrentValuePublisher<String?, Never>,
|
||||
userSettings: UserSettings,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
bugReportService: BugReportServiceProtocol,
|
||||
notificationManager: NotificationManagerProtocol,
|
||||
@@ -40,7 +39,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
self.userSession = userSession
|
||||
self.analyticsService = analyticsService
|
||||
self.bugReportService = bugReportService
|
||||
self.userSettings = userSettings
|
||||
userSettings = userSession.userSettings
|
||||
self.notificationManager = notificationManager
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
@@ -49,7 +48,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
roomSummaryProvider = userSession.clientProxy.roomSummaryProvider
|
||||
|
||||
super.init(initialViewState: .init(userProfile: userSession.clientProxy.userProfilePublisher.value,
|
||||
bindings: .init(filtersState: .init(userSettings: userSettings))),
|
||||
bindings: .init(filtersState: .init(userSettings: userSession.userSettings))),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
if userSettings.app.globalSearchEnabled, #available(iOS 26.0, *) {
|
||||
|
||||
@@ -237,7 +237,6 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
userSettings: .mock(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -145,7 +145,6 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview {
|
||||
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([])))))))
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
userSettings: .mock(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -201,7 +201,6 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
userSettings: .mock(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -133,7 +133,6 @@ struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
userSettings: .mock(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -122,7 +122,6 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
userSettings: .mock(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -13,7 +13,6 @@ struct JoinRoomScreenCoordinatorParameters {
|
||||
let source: JoinRoomScreenSource
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let userSettings: UserSettings
|
||||
}
|
||||
|
||||
enum JoinRoomScreenSource {
|
||||
@@ -53,7 +52,6 @@ final class JoinRoomScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: JoinRoomScreenCoordinatorParameters) {
|
||||
viewModel = JoinRoomScreenViewModel(source: parameters.source,
|
||||
userSettings: parameters.userSettings,
|
||||
userSession: parameters.userSession,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
@@ -30,11 +30,10 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
}
|
||||
|
||||
init(source: JoinRoomScreenSource,
|
||||
userSettings: UserSettings,
|
||||
userSession: UserSessionProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.source = source
|
||||
self.userSettings = userSettings
|
||||
userSettings = userSession.userSettings
|
||||
clientProxy = userSession.clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
@@ -49,7 +48,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
|
||||
context.$viewState.map(\.mode)
|
||||
.removeDuplicates()
|
||||
.sink { mode in
|
||||
.sink { [userSettings = self.userSettings] mode in
|
||||
switch mode {
|
||||
case .invited:
|
||||
userSettings.app.seenInvites.insert(roomID)
|
||||
|
||||
@@ -402,8 +402,6 @@ struct JoinRoomScreenPreviewWrapper: Identifiable {
|
||||
self.isSpace = isSpace
|
||||
self.customPreviewName = customPreviewName
|
||||
|
||||
let userSettings = UserSettings.mock()
|
||||
|
||||
let clientProxy = ClientProxyMock(.init(hideInviteAvatars: hideInviteAvatars))
|
||||
clientProxy.canJoinRoomWithReturnValue = canJoinRoom
|
||||
|
||||
@@ -455,7 +453,6 @@ struct JoinRoomScreenPreviewWrapper: Identifiable {
|
||||
}
|
||||
|
||||
viewModel = JoinRoomScreenViewModel(source: source,
|
||||
userSettings: userSettings,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
|
||||
@@ -14,12 +14,10 @@ struct LocationSharingScreenCoordinatorParameters {
|
||||
let mapURLBuilder: MapTilerURLBuilderProtocol
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let timelineController: TimelineControllerProtocol
|
||||
let liveLocationManager: LiveLocationManagerProtocol
|
||||
let userSettings: UserSettings
|
||||
let userSession: UserSessionProtocol
|
||||
let appMediator: AppMediatorProtocol
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let mediaProvider: MediaProviderProtocol
|
||||
}
|
||||
|
||||
enum LocationSharingScreenCoordinatorAction {
|
||||
@@ -44,11 +42,9 @@ final class LocationSharingScreenCoordinator: CoordinatorProtocol {
|
||||
mapURLBuilder: parameters.mapURLBuilder,
|
||||
roomProxy: parameters.roomProxy,
|
||||
timelineController: parameters.timelineController,
|
||||
liveLocationManager: parameters.liveLocationManager,
|
||||
userSettings: parameters.userSettings,
|
||||
userSession: parameters.userSession,
|
||||
analytics: parameters.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
mediaProvider: parameters.mediaProvider)
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
@@ -36,16 +36,14 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
mapURLBuilder: MapTilerURLBuilderProtocol,
|
||||
roomProxy: JoinedRoomProxyProtocol,
|
||||
timelineController: TimelineControllerProtocol,
|
||||
liveLocationManager: LiveLocationManagerProtocol,
|
||||
userSettings: UserSettings,
|
||||
userSession: UserSessionProtocol,
|
||||
analytics: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
notificationCenter: NotificationCenter = .default) {
|
||||
self.roomProxy = roomProxy
|
||||
self.timelineController = timelineController
|
||||
self.liveLocationManager = liveLocationManager
|
||||
self.userSettings = userSettings
|
||||
liveLocationManager = userSession.liveLocationManager
|
||||
userSettings = userSession.userSettings
|
||||
self.analytics = analytics
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.notificationCenter = notificationCenter
|
||||
@@ -53,7 +51,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
super.init(initialViewState: .init(interactionMode: interactionMode,
|
||||
mapURLBuilder: mapURLBuilder,
|
||||
ownUserID: roomProxy.ownUserID),
|
||||
mediaProvider: mediaProvider)
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
updateUserProfiles(members: roomProxy.membersPublisher.value)
|
||||
setupSubscriptions()
|
||||
@@ -432,16 +430,14 @@ extension LocationSharingScreenViewModel {
|
||||
let roomProxy = JoinedRoomProxyMock(.init(members: .allMembers, ownUserID: RoomMemberProxyMock.mockMe.userID))
|
||||
roomProxy.makeLiveLocationServiceReturnValue = liveLocationServiceMock
|
||||
|
||||
let userSettings = UserSettings.mock()
|
||||
let userSession = UserSessionMock(.init())
|
||||
|
||||
return LocationSharingScreenViewModel(interactionMode: interactionMode,
|
||||
mapURLBuilder: userSettings.app.mapTilerConfiguration.publisher.value,
|
||||
mapURLBuilder: userSession.userSettings.app.mapTilerConfiguration.publisher.value,
|
||||
roomProxy: roomProxy,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
liveLocationManager: LiveLocationManagerMock(),
|
||||
userSettings: userSettings,
|
||||
userSession: userSession,
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(.init()))
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -16,7 +16,6 @@ struct MediaEventsTimelineScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let mediaPlayerProvider: MediaPlayerProviderProtocol
|
||||
let appMediator: AppMediatorProtocol
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let emojiProvider: EmojiProviderProtocol
|
||||
let linkMetadataProvider: LinkMetadataProviderProtocol
|
||||
|
||||
+2
-4
@@ -33,8 +33,7 @@ enum SessionVerificationScreenFlow {
|
||||
struct SessionVerificationScreenCoordinatorParameters {
|
||||
let sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol
|
||||
let flow: SessionVerificationScreenFlow
|
||||
let userSettings: UserSettings
|
||||
let mediaProvider: MediaProviderProtocol
|
||||
let userSession: UserSessionProtocol
|
||||
}
|
||||
|
||||
final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
|
||||
@@ -50,8 +49,7 @@ final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: SessionVerificationScreenCoordinatorParameters) {
|
||||
viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: parameters.sessionVerificationControllerProxy,
|
||||
flow: parameters.flow,
|
||||
userSettings: parameters.userSettings,
|
||||
mediaProvider: parameters.mediaProvider)
|
||||
userSession: parameters.userSession)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
+3
-4
@@ -25,8 +25,7 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
|
||||
init(sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol,
|
||||
flow: SessionVerificationScreenFlow,
|
||||
userSettings: UserSettings,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
userSession: UserSessionProtocol,
|
||||
verificationState: SessionVerificationScreenStateMachine.State = .initial) {
|
||||
self.sessionVerificationControllerProxy = sessionVerificationControllerProxy
|
||||
self.flow = flow
|
||||
@@ -34,9 +33,9 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
stateMachine = SessionVerificationScreenStateMachine(state: verificationState)
|
||||
|
||||
super.init(initialViewState: .init(flow: flow,
|
||||
learnMoreURL: userSettings.app.encryptionURL,
|
||||
learnMoreURL: userSession.userSettings.app.encryptionURL,
|
||||
verificationState: verificationState),
|
||||
mediaProvider: mediaProvider)
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
setupStateMachine()
|
||||
|
||||
|
||||
+1
-2
@@ -289,8 +289,7 @@ struct SessionVerification_Previews: PreviewProvider, TestablePreview {
|
||||
flow: SessionVerificationScreenFlow = .deviceInitiator) -> some View {
|
||||
let viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: SessionVerificationControllerProxyMock.configureMock(),
|
||||
flow: flow,
|
||||
userSettings: .mock(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
verificationState: state)
|
||||
|
||||
return SessionVerificationScreen(context: viewModel.context)
|
||||
|
||||
+1
-2
@@ -15,7 +15,6 @@ struct PinnedEventsTimelineScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let mediaPlayerProvider: MediaPlayerProviderProtocol
|
||||
let appMediator: AppMediatorProtocol
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let emojiProvider: EmojiProviderProtocol
|
||||
let linkMetadataProvider: LinkMetadataProviderProtocol
|
||||
@@ -46,7 +45,7 @@ final class PinnedEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: PinnedEventsTimelineScreenCoordinatorParameters) {
|
||||
viewModel = PinnedEventsTimelineScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
userSettings: parameters.userSettings,
|
||||
userSettings: parameters.userSession.userSettings,
|
||||
analyticsService: parameters.analytics)
|
||||
timelineViewModel = TimelineViewModel(roomProxy: parameters.roomProxy,
|
||||
timelineController: parameters.timelineController,
|
||||
|
||||
@@ -12,7 +12,6 @@ import SwiftUI
|
||||
struct RoomDetailsScreenCoordinatorParameters {
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let userSession: UserSessionProtocol
|
||||
let userSettings: UserSettings
|
||||
let appHooks: AppHooks
|
||||
let analyticsService: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -54,7 +53,6 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
|
||||
isSpace = parameters.roomProxy.infoPublisher.value.isSpace
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
userSession: parameters.userSession,
|
||||
userSettings: parameters.userSettings,
|
||||
appHooks: parameters.appHooks,
|
||||
analyticsService: parameters.analyticsService,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
|
||||
@@ -45,7 +45,6 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
|
||||
init(roomProxy: JoinedRoomProxyProtocol,
|
||||
userSession: UserSessionProtocol,
|
||||
userSettings: UserSettings,
|
||||
appHooks: AppHooks,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
@@ -68,7 +67,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
topicSummary: topic?.unattributedStringByReplacingNewlinesWithSpaces(),
|
||||
joinedMembersCount: roomProxy.infoPublisher.value.joinedMembersCount,
|
||||
notificationSettingsState: .loading,
|
||||
isNativeCallingEnabled: userSettings.app.nativeCallEnabled,
|
||||
isNativeCallingEnabled: userSession.userSettings.app.nativeCallEnabled,
|
||||
bindings: .init())
|
||||
super.init(initialViewState: appHooks.roomDetailsScreenHook.update(viewState),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
@@ -445,7 +445,6 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
userSettings: UserSettings.mock(),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
@@ -474,7 +473,6 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
userSettings: UserSettings.mock(),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
@@ -513,7 +511,6 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
userSettings: UserSettings.mock(),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
|
||||
@@ -10,10 +10,8 @@ import SwiftUI
|
||||
|
||||
struct SearchScreenCoordinatorParameters {
|
||||
let roomSummaryProvider: RoomSummaryProviderProtocol
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let mediaProvider: MediaProviderProtocol
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let userSettings: UserSettings
|
||||
}
|
||||
|
||||
enum SearchScreenCoordinatorAction {
|
||||
@@ -33,10 +31,8 @@ final class SearchScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: SearchScreenCoordinatorParameters) {
|
||||
viewModel = SearchScreenViewModel(roomSummaryProvider: parameters.roomSummaryProvider,
|
||||
clientProxy: parameters.clientProxy,
|
||||
mediaProvider: parameters.mediaProvider,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
userSettings: parameters.userSettings)
|
||||
userSession: parameters.userSession,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
@@ -33,20 +33,18 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro
|
||||
}
|
||||
|
||||
init(roomSummaryProvider: RoomSummaryProviderProtocol,
|
||||
clientProxy: ClientProxyProtocol,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
userSession: UserSessionProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
userSettings: UserSettings,
|
||||
initialSearchQuery: String = "",
|
||||
initialSearchMode: SearchScreenMode = .rooms) {
|
||||
self.roomSummaryProvider = roomSummaryProvider
|
||||
self.clientProxy = clientProxy
|
||||
searchService = clientProxy.searchService
|
||||
clientProxy = userSession.clientProxy
|
||||
searchService = userSession.clientProxy.searchService
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.userSettings = userSettings
|
||||
userSettings = userSession.userSettings
|
||||
|
||||
super.init(initialViewState: SearchScreenViewState(bindings: .init(searchQuery: initialSearchQuery, searchMode: initialSearchMode)),
|
||||
mediaProvider: mediaProvider)
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
roomSummaryProvider.roomListPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
|
||||
@@ -626,46 +626,35 @@ private final class KeyNavigatingSearchTextField: UISearchTextField {
|
||||
|
||||
struct SearchScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let emptyViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))),
|
||||
clientProxy: makeClientProxy(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: UserSettings.mock())
|
||||
userSession: UserSessionMock(.init(clientProxy: makeClientProxy())),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
static let noResultsViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))),
|
||||
clientProxy: makeClientProxy(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userSession: UserSessionMock(.init(clientProxy: makeClientProxy())),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: UserSettings.mock(),
|
||||
initialSearchQuery: "John Doe")
|
||||
static let roomsViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
||||
clientProxy: makeClientProxy(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userSession: UserSessionMock(.init(clientProxy: makeClientProxy())),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: UserSettings.mock(),
|
||||
initialSearchQuery: "Foundation")
|
||||
static let messagesViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))),
|
||||
clientProxy: makeClientProxy(searchService: makeSearchService(results: .mockResults)),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userSession: UserSessionMock(.init(clientProxy: makeClientProxy(searchService: makeSearchService(results: .mockResults)))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: UserSettings.mock(),
|
||||
initialSearchQuery: "Foundation",
|
||||
initialSearchMode: .messages)
|
||||
static let loadingMessagesViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))),
|
||||
clientProxy: makeClientProxy(searchService: makeSearchService(paginationState: .loading)),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userSession: UserSessionMock(.init(clientProxy: makeClientProxy(searchService: makeSearchService(paginationState: .loading)))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: UserSettings.mock(),
|
||||
initialSearchQuery: "Foundation",
|
||||
initialSearchMode: .messages)
|
||||
|
||||
static let breadcrumbsViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))),
|
||||
clientProxy: makeClientProxy(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: makeUserSettings(breadcrumbs: [.room(roomID: "!room1:matrix.org"),
|
||||
.query("Bob"),
|
||||
.room(roomID: "!room5:matrix.org"),
|
||||
.query("Element HR"),
|
||||
.query("Alice")]))
|
||||
userSession: UserSessionMock(.init(clientProxy: makeClientProxy(),
|
||||
userSettings: makeUserSettings(breadcrumbs: [.room(roomID: "!room1:matrix.org"),
|
||||
.query("Bob"),
|
||||
.room(roomID: "!room5:matrix.org"),
|
||||
.query("Element HR"),
|
||||
.query("Alice")]))),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
|
||||
+2
-4
@@ -11,9 +11,8 @@ import SwiftUI
|
||||
|
||||
struct SecurityAndPrivacyScreenCoordinatorParameters {
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let appSetting: UserSettings
|
||||
let appHooks: AppHooks
|
||||
}
|
||||
|
||||
@@ -35,9 +34,8 @@ final class SecurityAndPrivacyScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: SecurityAndPrivacyScreenCoordinatorParameters) {
|
||||
viewModel = SecurityAndPrivacyScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
clientProxy: parameters.clientProxy,
|
||||
userSession: parameters.userSession,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
userSettings: parameters.appSetting,
|
||||
appHooks: parameters.appHooks)
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -24,14 +24,13 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
|
||||
}
|
||||
|
||||
init(roomProxy: JoinedRoomProxyProtocol,
|
||||
clientProxy: ClientProxyProtocol,
|
||||
userSession: UserSessionProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
userSettings: UserSettings,
|
||||
appHooks: AppHooks) {
|
||||
self.roomProxy = roomProxy
|
||||
self.clientProxy = clientProxy
|
||||
clientProxy = userSession.clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.userSettings = userSettings
|
||||
userSettings = userSession.userSettings
|
||||
|
||||
let viewState = SecurityAndPrivacyScreenViewState(accessType: roomProxy.infoPublisher.value.joinRule.toSecurityAndPrivacyRoomAccessType,
|
||||
isEncryptionEnabled: roomProxy.infoPublisher.value.isEncrypted,
|
||||
|
||||
+16
-26
@@ -233,9 +233,8 @@ struct SecurityAndPrivacyScreen: View {
|
||||
struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let inviteOnlyViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsCreator,
|
||||
joinRule: .invite)),
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: .mock(),
|
||||
appHooks: AppHooks())
|
||||
|
||||
static let publicViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false,
|
||||
@@ -243,22 +242,18 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .public,
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: .mock(),
|
||||
appHooks: AppHooks())
|
||||
|
||||
static let publicNoAddressViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false,
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .public)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: .mock(),
|
||||
appHooks: AppHooks())
|
||||
|
||||
static let singleSpaceMembersViewModel = {
|
||||
let userSettings = UserSettings.mock()
|
||||
|
||||
let space = [SpaceServiceRoom].mockSingleRoom[0]
|
||||
|
||||
return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false,
|
||||
@@ -266,16 +261,13 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .restricted(rules: [.roomMembership(roomID: space.id)]),
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: [space]))),
|
||||
userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: [space]))))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: userSettings,
|
||||
appHooks: AppHooks())
|
||||
}()
|
||||
|
||||
static let multipleSpacesMembersViewModel = {
|
||||
let userSettings = UserSettings.mock()
|
||||
|
||||
let spaces = [SpaceServiceRoom].mockJoinedSpaces
|
||||
|
||||
return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false,
|
||||
@@ -283,10 +275,9 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .restricted(rules: spaces.map { .roomMembership(roomID: $0.id) }),
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: spaces))),
|
||||
userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: spaces))))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: userSettings,
|
||||
appHooks: AppHooks())
|
||||
}()
|
||||
|
||||
@@ -299,9 +290,9 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .knock,
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userSettings: userSettings)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: userSettings,
|
||||
appHooks: AppHooks())
|
||||
}()
|
||||
|
||||
@@ -316,10 +307,10 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .knockRestricted(rules: [.roomMembership(roomID: space.id)]),
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: [space]))),
|
||||
userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: [space]))),
|
||||
userSettings: userSettings)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: userSettings,
|
||||
appHooks: AppHooks())
|
||||
}()
|
||||
|
||||
@@ -334,10 +325,10 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .knockRestricted(rules: spaces.map { .roomMembership(roomID: $0.id) }),
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: spaces))),
|
||||
userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: spaces))),
|
||||
userSettings: userSettings)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: userSettings,
|
||||
appHooks: AppHooks())
|
||||
}()
|
||||
|
||||
@@ -347,9 +338,8 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .public,
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userSettings: .mock(),
|
||||
appHooks: AppHooks())
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
+2
-3
@@ -15,7 +15,6 @@ struct NotificationSettingsScreenCoordinatorParameters {
|
||||
let userNotificationCenter: UserNotificationCenterProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let isModallyPresented: Bool
|
||||
let userSettings: UserSettings
|
||||
}
|
||||
|
||||
enum NotificationSettingsScreenCoordinatorAction {
|
||||
@@ -39,9 +38,9 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: NotificationSettingsScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
|
||||
viewModel = NotificationSettingsScreenViewModel(userSettings: parameters.userSettings,
|
||||
viewModel = NotificationSettingsScreenViewModel(userSettings: parameters.userSession.userSettings,
|
||||
userNotificationCenter: parameters.userNotificationCenter,
|
||||
notificationToneManager: NotificationToneManager(userSettings: parameters.userSettings),
|
||||
notificationToneManager: NotificationToneManager(userSettings: parameters.userSession.userSettings),
|
||||
notificationSettingsProxy: parameters.userSession.clientProxy.notificationSettings,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
isModallyPresented: parameters.isModallyPresented)
|
||||
|
||||
@@ -11,7 +11,6 @@ import SwiftUI
|
||||
|
||||
struct SettingsScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let userSettings: UserSettings
|
||||
let isBugReportServiceEnabled: Bool
|
||||
let isInSecondaryWindow: Bool
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -59,7 +58,6 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: SettingsScreenCoordinatorParameters) {
|
||||
viewModel = SettingsScreenViewModel(userSession: parameters.userSession,
|
||||
userSettings: parameters.userSettings,
|
||||
isBugReportServiceEnabled: parameters.isBugReportServiceEnabled,
|
||||
isInSecondaryWindow: parameters.isInSecondaryWindow,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
|
||||
@@ -22,8 +22,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(userSession: UserSessionProtocol, userSettings: UserSettings, isBugReportServiceEnabled: Bool, isInSecondaryWindow: Bool, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.userSettings = userSettings
|
||||
init(userSession: UserSessionProtocol, isBugReportServiceEnabled: Bool, isInSecondaryWindow: Bool, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
userSettings = userSession.userSettings
|
||||
clientProxy = userSession.clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
|
||||
@@ -313,15 +313,15 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
|
||||
static func makeViewModel(isBugReportServiceEnabled: Bool = true) -> SettingsScreenViewModel {
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@alice:example.com",
|
||||
deviceID: "AAAAAAAAAAA",
|
||||
displayName: "Alice Liddell",
|
||||
status: .mockFocussing))))
|
||||
let userSettings = UserSettings.mock()
|
||||
userSettings.app.multiAccountEnabled = true
|
||||
userSettings.app.linkNewDeviceEnabled = true
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@alice:example.com",
|
||||
deviceID: "AAAAAAAAAAA",
|
||||
displayName: "Alice Liddell",
|
||||
status: .mockFocussing)),
|
||||
userSettings: userSettings))
|
||||
return SettingsScreenViewModel(userSession: userSession,
|
||||
userSettings: userSettings,
|
||||
isBugReportServiceEnabled: isBugReportServiceEnabled,
|
||||
isInSecondaryWindow: false,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
@@ -132,7 +132,6 @@ struct SpaceSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
canonicalAlias: "#space:matrix.org",
|
||||
members: members)),
|
||||
userSession: UserSessionMock(.init()),
|
||||
userSettings: UserSettings.mock(),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
|
||||
@@ -21,7 +21,6 @@ struct ThreadTimelineScreenCoordinatorParameters {
|
||||
let linkMetadataProvider: LinkMetadataProviderProtocol
|
||||
let completionSuggestionService: CompletionSuggestionServiceProtocol
|
||||
let appMediator: AppMediatorProtocol
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let composerDraftService: ComposerDraftServiceProtocol
|
||||
let timelineControllerFactory: TimelineControllerFactoryProtocol
|
||||
@@ -56,7 +55,7 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
|
||||
init(parameters: ThreadTimelineScreenCoordinatorParameters) {
|
||||
userSettings = parameters.userSettings
|
||||
userSettings = parameters.userSession.userSettings
|
||||
|
||||
viewModel = ThreadTimelineScreenViewModel(roomProxy: parameters.roomProxy, userSession: parameters.userSession)
|
||||
|
||||
@@ -83,7 +82,7 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
completionSuggestionService: parameters.completionSuggestionService,
|
||||
mediaProvider: parameters.userSession.mediaProvider,
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper(timelineContext: timelineViewModel.context),
|
||||
userSettings: parameters.userSettings,
|
||||
userSettings: parameters.userSession.userSettings,
|
||||
analyticsService: parameters.analytics,
|
||||
composerDraftService: parameters.composerDraftService)
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ nonisolated struct ClientFactory: ClientFactoryProtocol {
|
||||
func makeNSEClient(credentials: KeychainCredentials,
|
||||
roomID: String,
|
||||
clientSessionDelegate: ClientSessionDelegate,
|
||||
userSettings: CommonSettingsProtocol,
|
||||
userSettings: UserSettings,
|
||||
appHooks: AppHooks) async throws -> ClientProtocol {
|
||||
let homeserverURL = credentials.restorationToken.session.homeserverUrl
|
||||
|
||||
@@ -90,10 +90,10 @@ nonisolated struct ClientFactory: ClientFactoryProtocol {
|
||||
discoverSlidingSync: false,
|
||||
sessionDelegate: clientSessionDelegate,
|
||||
appHooks: appHooks,
|
||||
enableOnlySignedDeviceIsolationMode: userSettings.enableOnlySignedDeviceIsolationMode,
|
||||
enableOnlySignedDeviceIsolationMode: userSettings.app.enableOnlySignedDeviceIsolationMode,
|
||||
requestTimeout: 15000,
|
||||
maxRequestRetryTime: 5000,
|
||||
threadsEnabled: userSettings.threadsEnabled)
|
||||
threadsEnabled: userSettings.app.threadsEnabled)
|
||||
.systemIsMemoryConstrained()
|
||||
.sqliteStore(config: .init(dataPath: credentials.restorationToken.sessionDirectories.dataPath,
|
||||
cachePath: credentials.restorationToken.sessionDirectories.cachePath)
|
||||
|
||||
@@ -36,6 +36,6 @@ nonisolated protocol ClientFactoryProtocol {
|
||||
func makeNSEClient(credentials: KeychainCredentials,
|
||||
roomID: String,
|
||||
clientSessionDelegate: ClientSessionDelegate,
|
||||
userSettings: CommonSettingsProtocol,
|
||||
userSettings: UserSettings,
|
||||
appHooks: AppHooks) async throws -> ClientProtocol
|
||||
}
|
||||
|
||||
@@ -597,8 +597,7 @@ class MockScreen: Identifiable {
|
||||
requestDelay: .seconds(5))
|
||||
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationControllerProxy,
|
||||
flow: .deviceInitiator,
|
||||
userSettings: .mock(),
|
||||
mediaProvider: MediaProviderMock(.init()))
|
||||
userSession: UserSessionMock(.init()))
|
||||
return SessionVerificationScreenCoordinator(parameters: parameters)
|
||||
case .userSessionScreen, .userSessionScreenReply, .userSessionSpacesFlow:
|
||||
let userID = "@mock:client.com"
|
||||
@@ -647,7 +646,6 @@ class MockScreen: Identifiable {
|
||||
emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: appMediator,
|
||||
userSettings: userSession.userSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
@@ -700,7 +698,6 @@ class MockScreen: Identifiable {
|
||||
emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
userSettings: userSession.userSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
@@ -801,7 +798,6 @@ class MockScreen: Identifiable {
|
||||
emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
userSettings: userSession.userSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
@@ -858,7 +854,6 @@ class MockScreen: Identifiable {
|
||||
emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
userSettings: userSession.userSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
|
||||
Reference in New Issue
Block a user