Remove all uses of the ServiceLocator from within Coordinators and View Models.

It is still used for mocks in tests, previews etc, and still used in the AppCoordinator.
This commit is contained in:
Doug
2025-08-27 16:05:49 +01:00
committed by Doug
parent dfb2425240
commit cb7d11fd13
23 changed files with 138 additions and 69 deletions
@@ -518,7 +518,8 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
navigationStackCoordinator: startChatNavigationStackCoordinator,
userDiscoveryService: userDiscoveryService,
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: flowParameters.appSettings),
appSettings: flowParameters.appSettings)
appSettings: flowParameters.appSettings,
analytics: flowParameters.analytics)
let coordinator = StartChatScreenCoordinator(parameters: parameters)
coordinator.actions.sink { [weak self] action in
@@ -578,7 +579,9 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
let callScreenCoordinator = CallScreenCoordinator(parameters: .init(elementCallService: flowParameters.elementCallService,
configuration: configuration,
allowPictureInPicture: true,
appHooks: flowParameters.appHooks))
appSettings: flowParameters.appSettings,
appHooks: flowParameters.appHooks,
analytics: flowParameters.analytics))
callScreenCoordinator.actions
.sink { [weak self] action in
@@ -652,6 +655,7 @@ class ChatsFlowCoordinator: FlowCoordinatorProtocol {
private func startEncryptionResetFlow(animated: Bool) {
let sheetNavigationStackCoordinator = NavigationStackCoordinator()
let parameters = EncryptionResetFlowCoordinatorParameters(userSession: userSession,
appSettings: flowParameters.appSettings,
userIndicatorController: flowParameters.userIndicatorController,
navigationStackCoordinator: sheetNavigationStackCoordinator,
windowManger: flowParameters.windowManager)
@@ -18,6 +18,7 @@ enum EncryptionResetFlowCoordinatorAction: Equatable {
struct EncryptionResetFlowCoordinatorParameters {
let userSession: UserSessionProtocol
let appSettings: AppSettings
let userIndicatorController: UserIndicatorControllerProtocol
let navigationStackCoordinator: NavigationStackCoordinator
let windowManger: WindowManagerProtocol
@@ -25,6 +26,7 @@ struct EncryptionResetFlowCoordinatorParameters {
class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol {
private let userSession: UserSessionProtocol
private let appSettings: AppSettings
private let userIndicatorController: UserIndicatorControllerProtocol
private let navigationStackCoordinator: NavigationStackCoordinator
@@ -59,6 +61,7 @@ class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol {
init(parameters: EncryptionResetFlowCoordinatorParameters) {
userSession = parameters.userSession
appSettings = parameters.appSettings
userIndicatorController = parameters.userIndicatorController
navigationStackCoordinator = parameters.navigationStackCoordinator
windowManager = parameters.windowManger
@@ -152,7 +155,9 @@ class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol {
private func presentOIDCAuthorization(for url: URL) {
// Note to anyone in the future if you come back here to make this open in Safari instead of a WAS.
// As of iOS 16, there is an issue on the simulator with accessing the cookie but it works on a device. 🤷‍♂️
accountSettingsPresenter = OIDCAccountSettingsPresenter(accountURL: url, presentationAnchor: windowManager.mainWindow)
accountSettingsPresenter = OIDCAccountSettingsPresenter(accountURL: url,
presentationAnchor: windowManager.mainWindow,
appSettings: appSettings)
accountSettingsPresenter?.start()
}
}
@@ -81,6 +81,8 @@ class MediaEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
mediaPlayerProvider: MediaPlayerProvider(),
voiceMessageMediaManager: userSession.voiceMessageMediaManager,
appMediator: flowParameters.appMediator,
appSettings: flowParameters.appSettings,
analytics: flowParameters.analytics,
emojiProvider: flowParameters.emojiProvider,
userIndicatorController: flowParameters.userIndicatorController,
timelineControllerFactory: flowParameters.timelineControllerFactory,
@@ -313,6 +313,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
private func startEncryptionResetFlow() {
let resetNavigationStackCoordinator = NavigationStackCoordinator()
let coordinator = EncryptionResetFlowCoordinator(parameters: .init(userSession: userSession,
appSettings: appSettings,
userIndicatorController: userIndicatorController,
navigationStackCoordinator: resetNavigationStackCoordinator,
windowManger: windowManager))
@@ -67,9 +67,12 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
mediaPlayerProvider: MediaPlayerProvider(),
voiceMessageMediaManager: userSession.voiceMessageMediaManager,
appMediator: flowParameters.appMediator,
appSettings: flowParameters.appSettings,
analytics: flowParameters.analytics,
emojiProvider: flowParameters.emojiProvider,
timelineControllerFactory: flowParameters.timelineControllerFactory,
clientProxy: userSession.clientProxy))
clientProxy: userSession.clientProxy,
userIndicatorController: flowParameters.userIndicatorController))
coordinator.actions
.sink { [weak self] action in
@@ -558,8 +558,10 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
appMediator: flowParameters.appMediator,
appSettings: flowParameters.appSettings,
appHooks: flowParameters.appHooks,
analytics: flowParameters.analytics,
composerDraftService: composerDraftService,
timelineControllerFactory: flowParameters.timelineControllerFactory)
timelineControllerFactory: flowParameters.timelineControllerFactory,
userIndicatorController: flowParameters.userIndicatorController)
let coordinator = RoomScreenCoordinator(parameters: parameters)
coordinator.actions
@@ -652,8 +654,10 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
completionSuggestionService: completionSuggestionService,
appMediator: flowParameters.appMediator,
appSettings: flowParameters.appSettings,
analytics: flowParameters.analytics,
composerDraftService: composerDraftService,
timelineControllerFactory: flowParameters.timelineControllerFactory))
timelineControllerFactory: flowParameters.timelineControllerFactory,
userIndicatorController: flowParameters.userIndicatorController))
coordinator.actions.sink { [weak self] action in
guard let self else { return }
@@ -779,7 +783,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
userIndicatorController: flowParameters.userIndicatorController,
notificationSettings: userSession.clientProxy.notificationSettings,
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
appMediator: flowParameters.appMediator)
appMediator: flowParameters.appMediator,
appSettings: flowParameters.appSettings)
let coordinator = RoomDetailsScreenCoordinator(parameters: params)
coordinator.actions.sink { [weak self] action in
guard let self else { return }
@@ -1185,7 +1190,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
let parameters = RoomPollsHistoryScreenCoordinatorParameters(pollInteractionHandler: PollInteractionHandler(analyticsService: flowParameters.analytics,
timelineController: timelineController),
timelineController: timelineController)
timelineController: timelineController,
userIndicatorController: flowParameters.userIndicatorController)
let coordinator = RoomPollsHistoryScreenCoordinator(parameters: parameters)
coordinator.actions
.sink { [weak self] action in
@@ -1322,7 +1328,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
let parameters = NotificationSettingsScreenCoordinatorParameters(navigationStackCoordinator: stackCoordinator,
userSession: userSession,
userNotificationCenter: UNUserNotificationCenter.current(),
isModallyPresented: true)
isModallyPresented: true,
appSettings: flowParameters.appSettings)
let coordinator = NotificationSettingsScreenCoordinator(parameters: parameters)
coordinator.actions.sink { [weak self] action in
switch action {
@@ -185,7 +185,8 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
let notificationParameters = NotificationSettingsScreenCoordinatorParameters(navigationStackCoordinator: navigationStackCoordinator,
userSession: flowParameters.userSession,
userNotificationCenter: UNUserNotificationCenter.current(),
isModallyPresented: false)
isModallyPresented: false,
appSettings: flowParameters.appSettings)
let coordinator = NotificationSettingsScreenCoordinator(parameters: notificationParameters)
navigationStackCoordinator.push(coordinator)
}
@@ -199,7 +200,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
}
private func presentDeveloperOptions() {
let coordinator = DeveloperOptionsScreenCoordinator()
let coordinator = DeveloperOptionsScreenCoordinator(appSettings: flowParameters.appSettings)
coordinator.actions
.sink { [weak self] action in
@@ -240,7 +241,9 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
private func presentAccountManagementURL(_ url: URL) {
// Note to anyone in the future if you come back here to make this open in Safari instead of a WAS.
// As of iOS 16, there is an issue on the simulator with accessing the cookie but it works on a device. 🤷‍♂️
accountSettingsPresenter = OIDCAccountSettingsPresenter(accountURL: url, presentationAnchor: flowParameters.windowManager.mainWindow)
accountSettingsPresenter = OIDCAccountSettingsPresenter(accountURL: url,
presentationAnchor: flowParameters.windowManager.mainWindow,
appSettings: flowParameters.appSettings)
accountSettingsPresenter?.start()
}
}