Finish splitting the App/User hooks. (#6348)

* Remove the homeserver parameter from user hooks.

* Split the OAuthPresenter hook into two.

With one living directly on the UserHooks.

* Add developerOptionsScreenHook to the UserHooks.

* Remove appHooks from the flowParameters.
This commit is contained in:
Doug
2026-10-19 16:28:18 +01:00
committed by GitHub
parent 066e806c13
commit 1ce7501e1b
34 changed files with 78 additions and 77 deletions
+8 -4
View File
@@ -291,6 +291,7 @@
2BBE320EE426A347AAE5C7DA /* IdentityConfirmationScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00AFC5F08734C2EA4EE79C59 /* IdentityConfirmationScreen.swift */; }; 2BBE320EE426A347AAE5C7DA /* IdentityConfirmationScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00AFC5F08734C2EA4EE79C59 /* IdentityConfirmationScreen.swift */; };
2BC579CB5CE90CFE07CA0955 /* EditRoomAddressScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41656BC6267D55C56A2AAC08 /* EditRoomAddressScreenCoordinator.swift */; }; 2BC579CB5CE90CFE07CA0955 /* EditRoomAddressScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41656BC6267D55C56A2AAC08 /* EditRoomAddressScreenCoordinator.swift */; };
2BFA4C6D5B3D327B02C66AB0 /* TimelineController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4216C12C0369A8AB059EDE9 /* TimelineController.swift */; }; 2BFA4C6D5B3D327B02C66AB0 /* TimelineController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4216C12C0369A8AB059EDE9 /* TimelineController.swift */; };
2C1C4D29EE0E5EF80BAEE390 /* OAuthAccountSettingsPresenterHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13A1CFE12BDB1D02BEDFFF6D /* OAuthAccountSettingsPresenterHook.swift */; };
2C289BECCCBEDBA48DC9AC67 /* ClassicAppMXAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74240BE69DACAD01AA670730 /* ClassicAppMXAccount.swift */; }; 2C289BECCCBEDBA48DC9AC67 /* ClassicAppMXAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74240BE69DACAD01AA670730 /* ClassicAppMXAccount.swift */; };
2C4C750D0039AFABDF24236C /* TemplateScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342BEBC3C5FC3F9943C41C4C /* TemplateScreenViewModelProtocol.swift */; }; 2C4C750D0039AFABDF24236C /* TemplateScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342BEBC3C5FC3F9943C41C4C /* TemplateScreenViewModelProtocol.swift */; };
2C5E832434EE94E21AB3B238 /* EmojiPickerScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3EAE3E9D5EF4A6D5D9C6CFD /* EmojiPickerScreenViewModel.swift */; }; 2C5E832434EE94E21AB3B238 /* EmojiPickerScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3EAE3E9D5EF4A6D5D9C6CFD /* EmojiPickerScreenViewModel.swift */; };
@@ -672,7 +673,6 @@
6832733838C57A7D3FE8FEB5 /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 50009897F60FAE7D63EF5E5B /* Kingfisher */; }; 6832733838C57A7D3FE8FEB5 /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 50009897F60FAE7D63EF5E5B /* Kingfisher */; };
6851B077B4C913CC12DB6E77 /* AppLockFlowCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCE93F0CBF0D96B77111C413 /* AppLockFlowCoordinator.swift */; }; 6851B077B4C913CC12DB6E77 /* AppLockFlowCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCE93F0CBF0D96B77111C413 /* AppLockFlowCoordinator.swift */; };
68B2DD307C57ECFABBB05323 /* DeclineAndBlockScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 127D1947BA9C6CA62E3D03EC /* DeclineAndBlockScreen.swift */; }; 68B2DD307C57ECFABBB05323 /* DeclineAndBlockScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 127D1947BA9C6CA62E3D03EC /* DeclineAndBlockScreen.swift */; };
68B7308BA24EC3DC5FD87B61 /* OAuthPresenterHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04CAC77224E949D8E758E2E3 /* OAuthPresenterHook.swift */; };
68C3AF257678F6E7BB238C3F /* AppAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FD22AEFFA20065494ED2333 /* AppAppearance.swift */; }; 68C3AF257678F6E7BB238C3F /* AppAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FD22AEFFA20065494ED2333 /* AppAppearance.swift */; };
695825D20A761C678809345D /* MessageForwardingScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52135BD9E0E7A091688F627A /* MessageForwardingScreenModels.swift */; }; 695825D20A761C678809345D /* MessageForwardingScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52135BD9E0E7A091688F627A /* MessageForwardingScreenModels.swift */; };
695BE6A2337A634F48B5DBC8 /* RoomMembersFlowCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC666DAE98245269775329B2 /* RoomMembersFlowCoordinatorTests.swift */; }; 695BE6A2337A634F48B5DBC8 /* RoomMembersFlowCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC666DAE98245269775329B2 /* RoomMembersFlowCoordinatorTests.swift */; };
@@ -938,6 +938,7 @@
8F2FAA98457750D9D664136F /* LoremSwiftum in Frameworks */ = {isa = PBXBuildFile; productRef = 1A6B622CCFDEFB92D9CF1CA5 /* LoremSwiftum */; }; 8F2FAA98457750D9D664136F /* LoremSwiftum in Frameworks */ = {isa = PBXBuildFile; productRef = 1A6B622CCFDEFB92D9CF1CA5 /* LoremSwiftum */; };
8F63A813760F3DDA8EA1DE9B /* test_image.png in Resources */ = {isa = PBXBuildFile; fileRef = 137C082DFC0157D66936A0EC /* test_image.png */; }; 8F63A813760F3DDA8EA1DE9B /* test_image.png in Resources */ = {isa = PBXBuildFile; fileRef = 137C082DFC0157D66936A0EC /* test_image.png */; };
8F7D29BD7FCBEC86B9E49CED /* preview_avatar_room.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 690915157A874D1F21ADE70C /* preview_avatar_room.jpg */; }; 8F7D29BD7FCBEC86B9E49CED /* preview_avatar_room.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 690915157A874D1F21ADE70C /* preview_avatar_room.jpg */; };
8F802A07E50399D10F471A64 /* OAuthAuthenticationPresenterHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A72DFD9E0508F021EA08247 /* OAuthAuthenticationPresenterHook.swift */; };
904F06C9C1AEF884C2077542 /* RoomDirectorySearchScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2E4EF80DFB8FE7C4469B15D /* RoomDirectorySearchScreen.swift */; }; 904F06C9C1AEF884C2077542 /* RoomDirectorySearchScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2E4EF80DFB8FE7C4469B15D /* RoomDirectorySearchScreen.swift */; };
90733645AE76FB33DAD28C2B /* URLSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE40D4A5DD857AC16EED945A /* URLSession.swift */; }; 90733645AE76FB33DAD28C2B /* URLSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE40D4A5DD857AC16EED945A /* URLSession.swift */; };
9097C3B61181B731CACEE28B /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2C6AE2DB4FE7FAEA6402663 /* Secrets.swift */; }; 9097C3B61181B731CACEE28B /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2C6AE2DB4FE7FAEA6402663 /* Secrets.swift */; };
@@ -1827,7 +1828,6 @@
048A21188AB19349D026BECD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; }; 048A21188AB19349D026BECD /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
04BB8DDE245ED86C489BA983 /* AccessibilityIdentifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityIdentifiers.swift; sourceTree = "<group>"; }; 04BB8DDE245ED86C489BA983 /* AccessibilityIdentifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityIdentifiers.swift; sourceTree = "<group>"; };
04C66FE72035CD1A870E8CB7 /* CoordinateAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoordinateAnimator.swift; sourceTree = "<group>"; }; 04C66FE72035CD1A870E8CB7 /* CoordinateAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoordinateAnimator.swift; sourceTree = "<group>"; };
04CAC77224E949D8E758E2E3 /* OAuthPresenterHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthPresenterHook.swift; sourceTree = "<group>"; };
04DF593C3F7AF4B2FBAEB05D /* FileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileManager.swift; sourceTree = "<group>"; }; 04DF593C3F7AF4B2FBAEB05D /* FileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileManager.swift; sourceTree = "<group>"; };
04EB6035C1F33F25F1EBFB7D /* RoomThreadListServiceProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomThreadListServiceProxyProtocol.swift; sourceTree = "<group>"; }; 04EB6035C1F33F25F1EBFB7D /* RoomThreadListServiceProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomThreadListServiceProxyProtocol.swift; sourceTree = "<group>"; };
0516C69708D5CBDE1A8E77EC /* RoomDirectorySearchProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDirectorySearchProxyProtocol.swift; sourceTree = "<group>"; }; 0516C69708D5CBDE1A8E77EC /* RoomDirectorySearchProxyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDirectorySearchProxyProtocol.swift; sourceTree = "<group>"; };
@@ -1863,6 +1863,7 @@
0A3534D37BFC074DD26F2FFE /* RoomThreadListScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomThreadListScreenModels.swift; sourceTree = "<group>"; }; 0A3534D37BFC074DD26F2FFE /* RoomThreadListScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomThreadListScreenModels.swift; sourceTree = "<group>"; };
0A3E77399BD262D301451BF2 /* RoomDetailsEditScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDetailsEditScreenCoordinator.swift; sourceTree = "<group>"; }; 0A3E77399BD262D301451BF2 /* RoomDetailsEditScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDetailsEditScreenCoordinator.swift; sourceTree = "<group>"; };
0A459AE4B6566B2FA99E86B2 /* TimelineItemBubbledStylerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineItemBubbledStylerView.swift; sourceTree = "<group>"; }; 0A459AE4B6566B2FA99E86B2 /* TimelineItemBubbledStylerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineItemBubbledStylerView.swift; sourceTree = "<group>"; };
0A72DFD9E0508F021EA08247 /* OAuthAuthenticationPresenterHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthAuthenticationPresenterHook.swift; sourceTree = "<group>"; };
0A81FD0C60175FA081EB19AD /* EventTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventTimelineItem.swift; sourceTree = "<group>"; }; 0A81FD0C60175FA081EB19AD /* EventTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventTimelineItem.swift; sourceTree = "<group>"; };
0AB7A0C06CB527A1095DEB33 /* da */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = da; path = da.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; 0AB7A0C06CB527A1095DEB33 /* da */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = da; path = da.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
0AC5E094DFE18C3AB7619D34 /* CreateRoomScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateRoomScreenViewModelProtocol.swift; sourceTree = "<group>"; }; 0AC5E094DFE18C3AB7619D34 /* CreateRoomScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateRoomScreenViewModelProtocol.swift; sourceTree = "<group>"; };
@@ -1928,6 +1929,7 @@
136F80A613B55BDD071DCEA5 /* JoinRoomScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinRoomScreenModels.swift; sourceTree = "<group>"; }; 136F80A613B55BDD071DCEA5 /* JoinRoomScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinRoomScreenModels.swift; sourceTree = "<group>"; };
137C082DFC0157D66936A0EC /* test_image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = test_image.png; sourceTree = "<group>"; }; 137C082DFC0157D66936A0EC /* test_image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = test_image.png; sourceTree = "<group>"; };
13802897C7AFA360EA74C0B0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; 13802897C7AFA360EA74C0B0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
13A1CFE12BDB1D02BEDFFF6D /* OAuthAccountSettingsPresenterHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthAccountSettingsPresenterHook.swift; sourceTree = "<group>"; };
13BE9781699FB510E9263192 /* AppSettingsHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettingsHook.swift; sourceTree = "<group>"; }; 13BE9781699FB510E9263192 /* AppSettingsHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettingsHook.swift; sourceTree = "<group>"; };
13F354AD441E2FD83DED89AF /* SeparatorMediaEventsTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeparatorMediaEventsTimelineView.swift; sourceTree = "<group>"; }; 13F354AD441E2FD83DED89AF /* SeparatorMediaEventsTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeparatorMediaEventsTimelineView.swift; sourceTree = "<group>"; };
1423AB065857FA546444DB15 /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = "<group>"; }; 1423AB065857FA546444DB15 /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = "<group>"; };
@@ -4076,7 +4078,8 @@
8B89D6C760E8CAE29CA28FB1 /* CompoundHook.swift */, 8B89D6C760E8CAE29CA28FB1 /* CompoundHook.swift */,
2F374C789B4BD1C597394987 /* CreateRoomScreenHook.swift */, 2F374C789B4BD1C597394987 /* CreateRoomScreenHook.swift */,
0F60FDB3AEFC60830BD289FE /* DeveloperOptionsScreenHook.swift */, 0F60FDB3AEFC60830BD289FE /* DeveloperOptionsScreenHook.swift */,
04CAC77224E949D8E758E2E3 /* OAuthPresenterHook.swift */, 13A1CFE12BDB1D02BEDFFF6D /* OAuthAccountSettingsPresenterHook.swift */,
0A72DFD9E0508F021EA08247 /* OAuthAuthenticationPresenterHook.swift */,
7AE97AD18893E2D8120F559D /* RecoveryKeyScreenHook.swift */, 7AE97AD18893E2D8120F559D /* RecoveryKeyScreenHook.swift */,
D5D186A6DB8FAC5C9D0E4D61 /* RemoteSettingsHook.swift */, D5D186A6DB8FAC5C9D0E4D61 /* RemoteSettingsHook.swift */,
3674212CAB6C5143DD437AC4 /* RoomDetailsScreenHook.swift */, 3674212CAB6C5143DD437AC4 /* RoomDetailsScreenHook.swift */,
@@ -9353,9 +9356,10 @@
101C8BFCAE35F43F37A6D8ED /* NotificationToneManagerMock.swift in Sources */, 101C8BFCAE35F43F37A6D8ED /* NotificationToneManagerMock.swift in Sources */,
1E414736CCF094E2CBD8E482 /* NotificationToneManagerProtocol.swift in Sources */, 1E414736CCF094E2CBD8E482 /* NotificationToneManagerProtocol.swift in Sources */,
6AC798F52571BE495E6AA1CE /* OAuthAccountSettingsPresenter.swift in Sources */, 6AC798F52571BE495E6AA1CE /* OAuthAccountSettingsPresenter.swift in Sources */,
2C1C4D29EE0E5EF80BAEE390 /* OAuthAccountSettingsPresenterHook.swift in Sources */,
E32E71A1AF5E5E69E8363B26 /* OAuthAuthenticationPresenter.swift in Sources */, E32E71A1AF5E5E69E8363B26 /* OAuthAuthenticationPresenter.swift in Sources */,
8F802A07E50399D10F471A64 /* OAuthAuthenticationPresenterHook.swift in Sources */,
C525F6C2892CB0640E776B3D /* OAuthConfiguration.swift in Sources */, C525F6C2892CB0640E776B3D /* OAuthConfiguration.swift in Sources */,
68B7308BA24EC3DC5FD87B61 /* OAuthPresenterHook.swift in Sources */,
FD573B5D665824EB79EABF06 /* Observable.swift in Sources */, FD573B5D665824EB79EABF06 /* Observable.swift in Sources */,
11A6B8E3CBDBF0A4107FF4CE /* OnboardingFlowCoordinator.swift in Sources */, 11A6B8E3CBDBF0A4107FF4CE /* OnboardingFlowCoordinator.swift in Sources */,
3CE4C5071B6D2576E2473989 /* OrderedSet.swift in Sources */, 3CE4C5071B6D2576E2473989 /* OrderedSet.swift in Sources */,
+2 -2
View File
@@ -21,8 +21,8 @@ final nonisolated class AppHooks: AppHooksProtocol {
@AppHook(default: DefaultBugReportHook()) @AppHook(default: DefaultBugReportHook())
var bugReportHook: BugReportHookProtocol var bugReportHook: BugReportHookProtocol
@AppHook(default: DefaultOAuthPresenterHook()) @AppHook(default: DefaultOAuthAuthenticationPresenterHook())
var oAuthPresenterHook: OAuthPresenterHookProtocol var oAuthAuthenticationPresenterHook: OAuthAuthenticationPresenterHookProtocol
@AppHook(default: DefaultDeveloperOptionsScreenHook()) @AppHook(default: DefaultDeveloperOptionsScreenHook())
var developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol var developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol
@@ -8,11 +8,11 @@
import Foundation import Foundation
nonisolated protocol CreateRoomScreenHookProtocol: Sendable { nonisolated protocol CreateRoomScreenHookProtocol: Sendable {
@MainActor func update(_ viewState: CreateRoomScreenViewState, homeserver: String) -> CreateRoomScreenViewState @MainActor func update(_ viewState: CreateRoomScreenViewState) -> CreateRoomScreenViewState
} }
struct DefaultCreateRoomScreenHook: CreateRoomScreenHookProtocol { struct DefaultCreateRoomScreenHook: CreateRoomScreenHookProtocol {
func update(_ viewState: CreateRoomScreenViewState, homeserver: String) -> CreateRoomScreenViewState { func update(_ viewState: CreateRoomScreenViewState) -> CreateRoomScreenViewState {
viewState viewState
} }
} }
@@ -8,11 +8,11 @@
import SwiftUI import SwiftUI
nonisolated protocol DeveloperOptionsScreenHookProtocol: Sendable { nonisolated protocol DeveloperOptionsScreenHookProtocol: Sendable {
func generalSectionRows(isSignedIn: Bool) -> AnyView? func generalSectionRows() -> AnyView?
} }
struct DefaultDeveloperOptionsScreenHook: DeveloperOptionsScreenHookProtocol { struct DefaultDeveloperOptionsScreenHook: DeveloperOptionsScreenHookProtocol {
func generalSectionRows(isSignedIn: Bool) -> AnyView? { func generalSectionRows() -> AnyView? {
nil nil
} }
} }
@@ -8,11 +8,11 @@
import Foundation import Foundation
nonisolated protocol OAuthPresenterHookProtocol: Sendable { nonisolated protocol OAuthAccountSettingsPresenterHookProtocol: Sendable {
@MainActor func update(_ url: URL) -> URL @MainActor func update(_ url: URL) -> URL
} }
struct DefaultOAuthPresenterHook: OAuthPresenterHookProtocol { struct DefaultOAuthAccountSettingsPresenterHook: OAuthAccountSettingsPresenterHookProtocol {
func update(_ url: URL) -> URL { func update(_ url: URL) -> URL {
url url
} }
@@ -0,0 +1,18 @@
//
// Copyright 2026 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Foundation
nonisolated protocol OAuthAuthenticationPresenterHookProtocol: Sendable {
@MainActor func update(_ url: URL, homeserver: String) -> URL
}
struct DefaultOAuthAuthenticationPresenterHook: OAuthAuthenticationPresenterHookProtocol {
func update(_ url: URL, homeserver: String) -> URL {
url
}
}
@@ -13,11 +13,11 @@ import SwiftUI
} }
nonisolated protocol RecoveryKeyScreenHookProtocol: Sendable { nonisolated protocol RecoveryKeyScreenHookProtocol: Sendable {
@MainActor func makeCoordinator(parameters: SecureBackupRecoveryKeyScreenCoordinatorParameters, homeserver: String) -> any SecureBackupRecoveryKeyCoordinatorProtocol @MainActor func makeCoordinator(parameters: SecureBackupRecoveryKeyScreenCoordinatorParameters) -> any SecureBackupRecoveryKeyCoordinatorProtocol
} }
struct DefaultRecoveryKeyScreenHook: RecoveryKeyScreenHookProtocol { struct DefaultRecoveryKeyScreenHook: RecoveryKeyScreenHookProtocol {
@MainActor func makeCoordinator(parameters: SecureBackupRecoveryKeyScreenCoordinatorParameters, homeserver: String) -> any SecureBackupRecoveryKeyCoordinatorProtocol { @MainActor func makeCoordinator(parameters: SecureBackupRecoveryKeyScreenCoordinatorParameters) -> any SecureBackupRecoveryKeyCoordinatorProtocol {
SecureBackupRecoveryKeyScreenCoordinator(parameters: parameters) SecureBackupRecoveryKeyScreenCoordinator(parameters: parameters)
} }
} }
@@ -8,11 +8,11 @@
import Foundation import Foundation
nonisolated protocol SecurityAndPrivacyScreenHookProtocol: Sendable { nonisolated protocol SecurityAndPrivacyScreenHookProtocol: Sendable {
@MainActor func update(_ viewState: SecurityAndPrivacyScreenViewState, homeserver: String) -> SecurityAndPrivacyScreenViewState @MainActor func update(_ viewState: SecurityAndPrivacyScreenViewState) -> SecurityAndPrivacyScreenViewState
} }
struct DefaultSecurityAndPrivacyScreenHook: SecurityAndPrivacyScreenHookProtocol { struct DefaultSecurityAndPrivacyScreenHook: SecurityAndPrivacyScreenHookProtocol {
func update(_ viewState: SecurityAndPrivacyScreenViewState, homeserver: String) -> SecurityAndPrivacyScreenViewState { func update(_ viewState: SecurityAndPrivacyScreenViewState) -> SecurityAndPrivacyScreenViewState {
viewState viewState
} }
} }
+7 -1
View File
@@ -15,6 +15,8 @@ nonisolated struct UserHooks: Sendable {
let recoveryKeyScreenHook: RecoveryKeyScreenHookProtocol let recoveryKeyScreenHook: RecoveryKeyScreenHookProtocol
let createRoomScreenHook: CreateRoomScreenHookProtocol let createRoomScreenHook: CreateRoomScreenHookProtocol
let securityAndPrivacyScreenHook: SecurityAndPrivacyScreenHookProtocol let securityAndPrivacyScreenHook: SecurityAndPrivacyScreenHookProtocol
let oAuthAccountSettingsPresenterHook: OAuthAccountSettingsPresenterHookProtocol
let developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol
init(roomScreenHook: RoomScreenHookProtocol = DefaultRoomScreenHook(), init(roomScreenHook: RoomScreenHookProtocol = DefaultRoomScreenHook(),
roomDetailsScreenHook: RoomDetailsScreenHookProtocol = DefaultRoomDetailsScreenHook(), roomDetailsScreenHook: RoomDetailsScreenHookProtocol = DefaultRoomDetailsScreenHook(),
@@ -22,7 +24,9 @@ nonisolated struct UserHooks: Sendable {
userProfileScreenHook: UserProfileScreenHookProtocol = DefaultUserProfileScreenHook(), userProfileScreenHook: UserProfileScreenHookProtocol = DefaultUserProfileScreenHook(),
recoveryKeyScreenHook: RecoveryKeyScreenHookProtocol = DefaultRecoveryKeyScreenHook(), recoveryKeyScreenHook: RecoveryKeyScreenHookProtocol = DefaultRecoveryKeyScreenHook(),
createRoomScreenHook: CreateRoomScreenHookProtocol = DefaultCreateRoomScreenHook(), createRoomScreenHook: CreateRoomScreenHookProtocol = DefaultCreateRoomScreenHook(),
securityAndPrivacyScreenHook: SecurityAndPrivacyScreenHookProtocol = DefaultSecurityAndPrivacyScreenHook()) { securityAndPrivacyScreenHook: SecurityAndPrivacyScreenHookProtocol = DefaultSecurityAndPrivacyScreenHook(),
oAuthAccountSettingsPresenterHook: OAuthAccountSettingsPresenterHookProtocol = DefaultOAuthAccountSettingsPresenterHook(),
developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol = DefaultDeveloperOptionsScreenHook()) {
self.roomScreenHook = roomScreenHook self.roomScreenHook = roomScreenHook
self.roomDetailsScreenHook = roomDetailsScreenHook self.roomDetailsScreenHook = roomDetailsScreenHook
self.roomMemberDetailsScreenHook = roomMemberDetailsScreenHook self.roomMemberDetailsScreenHook = roomMemberDetailsScreenHook
@@ -30,5 +34,7 @@ nonisolated struct UserHooks: Sendable {
self.recoveryKeyScreenHook = recoveryKeyScreenHook self.recoveryKeyScreenHook = recoveryKeyScreenHook
self.createRoomScreenHook = createRoomScreenHook self.createRoomScreenHook = createRoomScreenHook
self.securityAndPrivacyScreenHook = securityAndPrivacyScreenHook self.securityAndPrivacyScreenHook = securityAndPrivacyScreenHook
self.oAuthAccountSettingsPresenterHook = oAuthAccountSettingsPresenterHook
self.developerOptionsScreenHook = developerOptionsScreenHook
} }
} }
@@ -894,7 +894,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
emojiProvider: EmojiProvider(userSettings: userSession.userSettings), emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: appMediator, appMediator: appMediator,
appHooks: appHooks,
analytics: analyticsService, analytics: analyticsService,
userIndicatorController: userIndicatorController, userIndicatorController: userIndicatorController,
stateMachineFactory: StateMachineFactory()) stateMachineFactory: StateMachineFactory())
@@ -34,7 +34,6 @@ struct CommonFlowParameters {
let emojiProvider: EmojiProviderProtocol let emojiProvider: EmojiProviderProtocol
let linkMetadataProvider: LinkMetadataProviderProtocol let linkMetadataProvider: LinkMetadataProviderProtocol
let appMediator: AppMediatorProtocol let appMediator: AppMediatorProtocol
let appHooks: AppHooks
let analytics: AnalyticsServiceProtocol let analytics: AnalyticsServiceProtocol
let userIndicatorController: UserIndicatorControllerProtocol let userIndicatorController: UserIndicatorControllerProtocol
let stateMachineFactory: StateMachineFactoryProtocol let stateMachineFactory: StateMachineFactoryProtocol
@@ -378,7 +378,7 @@ class AuthenticationFlowCoordinator: FlowCoordinatorProtocol {
redirectURL: appSettings.oAuthRedirectURL, redirectURL: appSettings.oAuthRedirectURL,
presentationAnchor: presentationAnchor, presentationAnchor: presentationAnchor,
appMediator: appMediator, appMediator: appMediator,
appHooks: appHooks, presenterHook: appHooks.oAuthAuthenticationPresenterHook,
userIndicatorController: userIndicatorController) userIndicatorController: userIndicatorController)
oAuthPresenter = presenter oAuthPresenter = presenter
@@ -443,7 +443,7 @@ class AuthenticationFlowCoordinator: FlowCoordinatorProtocol {
private func showDeveloperOptionsScreen() { private func showDeveloperOptionsScreen() {
let stackCoordinator = NavigationStackCoordinator() let stackCoordinator = NavigationStackCoordinator()
let coordinator = DeveloperOptionsScreenCoordinator(appSettings: appSettings, let coordinator = DeveloperOptionsScreenCoordinator(appSettings: appSettings,
appHooks: appHooks, screenHook: appHooks.developerOptionsScreenHook,
clientProxy: nil) clientProxy: nil)
coordinator.actions coordinator.actions
.sink { action in .sink { action in
@@ -658,8 +658,7 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
userIndicatorController: flowParameters.userIndicatorController, userIndicatorController: flowParameters.userIndicatorController,
isModallyPresented: true) isModallyPresented: true)
let coordinator = userSession.userHooks.recoveryKeyScreenHook.makeCoordinator(parameters: parameters, let coordinator = userSession.userHooks.recoveryKeyScreenHook.makeCoordinator(parameters: parameters)
homeserver: userSession.clientProxy.homeserver)
coordinator.actions.sink { [weak self] action in coordinator.actions.sink { [weak self] action in
guard let self else { return } guard let self else { return }
switch action { switch action {
@@ -680,7 +679,6 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
let sheetNavigationStackCoordinator = NavigationStackCoordinator() let sheetNavigationStackCoordinator = NavigationStackCoordinator()
let parameters = EncryptionResetFlowCoordinatorParameters(userSession: userSession, let parameters = EncryptionResetFlowCoordinatorParameters(userSession: userSession,
appMediator: flowParameters.appMediator, appMediator: flowParameters.appMediator,
appHooks: flowParameters.appHooks,
userIndicatorController: flowParameters.userIndicatorController, userIndicatorController: flowParameters.userIndicatorController,
navigationStackCoordinator: sheetNavigationStackCoordinator, navigationStackCoordinator: sheetNavigationStackCoordinator,
windowManger: flowParameters.windowManager) windowManger: flowParameters.windowManager)
@@ -20,7 +20,6 @@ enum EncryptionResetFlowCoordinatorAction: Equatable {
struct EncryptionResetFlowCoordinatorParameters { struct EncryptionResetFlowCoordinatorParameters {
let userSession: UserSessionProtocol let userSession: UserSessionProtocol
let appMediator: AppMediatorProtocol let appMediator: AppMediatorProtocol
let appHooks: AppHooks
let userIndicatorController: UserIndicatorControllerProtocol let userIndicatorController: UserIndicatorControllerProtocol
let navigationStackCoordinator: NavigationStackCoordinator let navigationStackCoordinator: NavigationStackCoordinator
let windowManger: WindowManagerProtocol let windowManger: WindowManagerProtocol
@@ -29,8 +28,6 @@ struct EncryptionResetFlowCoordinatorParameters {
class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol { class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol {
private let userSession: UserSessionProtocol private let userSession: UserSessionProtocol
private let appMediator: AppMediatorProtocol private let appMediator: AppMediatorProtocol
private let userSettings: UserSettings
private let appHooks: AppHooks
private let userIndicatorController: UserIndicatorControllerProtocol private let userIndicatorController: UserIndicatorControllerProtocol
private let navigationStackCoordinator: NavigationStackCoordinator private let navigationStackCoordinator: NavigationStackCoordinator
@@ -66,8 +63,6 @@ class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol {
init(parameters: EncryptionResetFlowCoordinatorParameters) { init(parameters: EncryptionResetFlowCoordinatorParameters) {
userSession = parameters.userSession userSession = parameters.userSession
appMediator = parameters.appMediator appMediator = parameters.appMediator
userSettings = parameters.userSession.userSettings
appHooks = parameters.appHooks
userIndicatorController = parameters.userIndicatorController userIndicatorController = parameters.userIndicatorController
navigationStackCoordinator = parameters.navigationStackCoordinator navigationStackCoordinator = parameters.navigationStackCoordinator
windowManager = parameters.windowManger windowManager = parameters.windowManger
@@ -164,8 +159,7 @@ class EncryptionResetFlowCoordinator: FlowCoordinatorProtocol {
accountSettingsPresenter = OAuthAccountSettingsPresenter(accountURL: url, accountSettingsPresenter = OAuthAccountSettingsPresenter(accountURL: url,
presentationAnchor: windowManager.mainWindow, presentationAnchor: windowManager.mainWindow,
appMediator: appMediator, appMediator: appMediator,
userSettings: userSettings, userSession: userSession)
appHooks: appHooks)
accountSettingsPresenter?.start() accountSettingsPresenter?.start()
} }
} }
@@ -160,8 +160,7 @@ class EncryptionSettingsFlowCoordinator: FlowCoordinatorProtocol {
let parameters = SecureBackupRecoveryKeyScreenCoordinatorParameters(secureBackupController: userSession.clientProxy.secureBackupController, let parameters = SecureBackupRecoveryKeyScreenCoordinatorParameters(secureBackupController: userSession.clientProxy.secureBackupController,
userIndicatorController: userIndicatorController, userIndicatorController: userIndicatorController,
isModallyPresented: true) isModallyPresented: true)
let coordinator = userSession.userHooks.recoveryKeyScreenHook.makeCoordinator(parameters: parameters, let coordinator = userSession.userHooks.recoveryKeyScreenHook.makeCoordinator(parameters: parameters)
homeserver: userSession.clientProxy.homeserver)
coordinator.actions.sink { [weak self] action in coordinator.actions.sink { [weak self] action in
guard let self else { return } guard let self else { return }
@@ -22,7 +22,6 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
private let analyticsService: AnalyticsServiceProtocol private let analyticsService: AnalyticsServiceProtocol
private let appMediator: AppMediatorProtocol private let appMediator: AppMediatorProtocol
private let userSettings: UserSettings private let userSettings: UserSettings
private let appHooks: AppHooks
private let userIndicatorController: UserIndicatorControllerProtocol private let userIndicatorController: UserIndicatorControllerProtocol
private let windowManager: WindowManagerProtocol private let windowManager: WindowManagerProtocol
private var isNewLogin: Bool private var isNewLogin: Bool
@@ -69,7 +68,6 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
analyticsService = flowParameters.analytics analyticsService = flowParameters.analytics
appMediator = flowParameters.appMediator appMediator = flowParameters.appMediator
userSettings = flowParameters.userSession.userSettings userSettings = flowParameters.userSession.userSettings
appHooks = flowParameters.appHooks
userIndicatorController = flowParameters.userIndicatorController userIndicatorController = flowParameters.userIndicatorController
windowManager = flowParameters.windowManager windowManager = flowParameters.windowManager
@@ -300,8 +298,7 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
userIndicatorController: userIndicatorController, userIndicatorController: userIndicatorController,
isModallyPresented: false) isModallyPresented: false)
let coordinator = userSession.userHooks.recoveryKeyScreenHook.makeCoordinator(parameters: parameters, let coordinator = userSession.userHooks.recoveryKeyScreenHook.makeCoordinator(parameters: parameters)
homeserver: userSession.clientProxy.homeserver)
coordinator.actions coordinator.actions
.sink { action in .sink { action in
@@ -319,7 +316,6 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
let resetNavigationStackCoordinator = NavigationStackCoordinator() let resetNavigationStackCoordinator = NavigationStackCoordinator()
let coordinator = EncryptionResetFlowCoordinator(parameters: .init(userSession: userSession, let coordinator = EncryptionResetFlowCoordinator(parameters: .init(userSession: userSession,
appMediator: appMediator, appMediator: appMediator,
appHooks: appHooks,
userIndicatorController: userIndicatorController, userIndicatorController: userIndicatorController,
navigationStackCoordinator: resetNavigationStackCoordinator, navigationStackCoordinator: resetNavigationStackCoordinator,
windowManger: windowManager)) windowManger: windowManager))
@@ -315,7 +315,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
private func presentDeveloperOptions() { private func presentDeveloperOptions() {
let coordinator = DeveloperOptionsScreenCoordinator(appSettings: userSettings.app, let coordinator = DeveloperOptionsScreenCoordinator(appSettings: userSettings.app,
appHooks: flowParameters.appHooks, screenHook: flowParameters.userSession.userHooks.developerOptionsScreenHook,
clientProxy: flowParameters.userSession.clientProxy) clientProxy: flowParameters.userSession.clientProxy)
coordinator.actions coordinator.actions
@@ -360,8 +360,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
accountSettingsPresenter = OAuthAccountSettingsPresenter(accountURL: url, accountSettingsPresenter = OAuthAccountSettingsPresenter(accountURL: url,
presentationAnchor: flowParameters.windowManager.mainWindow, presentationAnchor: flowParameters.windowManager.mainWindow,
appMediator: flowParameters.appMediator, appMediator: flowParameters.appMediator,
userSettings: userSettings, userSession: flowParameters.userSession,
appHooks: flowParameters.appHooks,
continuation: continuation) continuation: continuation)
accountSettingsPresenter?.start() accountSettingsPresenter?.start()
} }
@@ -18,7 +18,7 @@ class OAuthAuthenticationPresenter: NSObject {
private let redirectURL: URL private let redirectURL: URL
private let presentationAnchor: UIWindow private let presentationAnchor: UIWindow
private let appMediator: AppMediatorProtocol private let appMediator: AppMediatorProtocol
private let appHooks: AppHooks private let presenterHook: OAuthAuthenticationPresenterHookProtocol
private let userIndicatorController: UserIndicatorControllerProtocol private let userIndicatorController: UserIndicatorControllerProtocol
/// The data required to complete a request. /// The data required to complete a request.
@@ -39,13 +39,13 @@ class OAuthAuthenticationPresenter: NSObject {
redirectURL: URL, redirectURL: URL,
presentationAnchor: UIWindow, presentationAnchor: UIWindow,
appMediator: AppMediatorProtocol, appMediator: AppMediatorProtocol,
appHooks: AppHooks, presenterHook: OAuthAuthenticationPresenterHookProtocol,
userIndicatorController: UserIndicatorControllerProtocol) { userIndicatorController: UserIndicatorControllerProtocol) {
self.authenticationService = authenticationService self.authenticationService = authenticationService
self.redirectURL = redirectURL self.redirectURL = redirectURL
self.presentationAnchor = presentationAnchor self.presentationAnchor = presentationAnchor
self.appMediator = appMediator self.appMediator = appMediator
self.appHooks = appHooks self.presenterHook = presenterHook
self.userIndicatorController = userIndicatorController self.userIndicatorController = userIndicatorController
super.init() super.init()
} }
@@ -56,7 +56,7 @@ class OAuthAuthenticationPresenter: NSObject {
/// In particular if the authentication URL requires opening an external app, then the user may return /// In particular if the authentication URL requires opening an external app, then the user may return
/// to the app without completing (or cancelling) the authentication. /// to the app without completing (or cancelling) the authentication.
func authenticate(using oAuthData: OAuthAuthorizationDataProxy) async -> Result<UserSessionProtocol, AuthenticationServiceError> { func authenticate(using oAuthData: OAuthAuthorizationDataProxy) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
let authenticationURL = appHooks.oAuthPresenterHook.update(oAuthData.url) let authenticationURL = presenterHook.update(oAuthData.url, homeserver: oAuthData.homeserver)
let response = await withCheckedContinuation { continuation in let response = await withCheckedContinuation { continuation in
let session = ASWebAuthenticationSession(url: authenticationURL, callback: .oAuthRedirectURL(redirectURL)) { url, error in let session = ASWebAuthenticationSession(url: authenticationURL, callback: .oAuthRedirectURL(redirectURL)) { url, error in
@@ -161,7 +161,7 @@ final class SoftLogoutScreenCoordinator: CoordinatorProtocol {
redirectURL: parameters.appSettings.oAuthRedirectURL, redirectURL: parameters.appSettings.oAuthRedirectURL,
presentationAnchor: presentationAnchor, presentationAnchor: presentationAnchor,
appMediator: parameters.appMediator, appMediator: parameters.appMediator,
appHooks: parameters.appHooks, presenterHook: parameters.appHooks.oAuthAuthenticationPresenterHook,
userIndicatorController: parameters.userIndicatorController) userIndicatorController: parameters.userIndicatorController)
self.oAuthPresenter = presenter self.oAuthPresenter = presenter
switch await presenter.authenticate(using: oAuthData) { switch await presenter.authenticate(using: oAuthData) {
@@ -67,7 +67,7 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen
aliasLocalPart: roomAliasNameFromRoomDisplayName(roomName: ""), aliasLocalPart: roomAliasNameFromRoomDisplayName(roomName: ""),
bindings: bindings) bindings: bindings)
super.init(initialViewState: userSession.userHooks.createRoomScreenHook.update(viewState, homeserver: userSession.clientProxy.homeserver), super.init(initialViewState: userSession.userHooks.createRoomScreenHook.update(viewState),
mediaProvider: userSession.mediaProvider) mediaProvider: userSession.mediaProvider)
setupBindings() setupBindings()
@@ -38,7 +38,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
isKnockingEnabled: userSettings.app.knockingEnabled, isKnockingEnabled: userSettings.app.knockingEnabled,
historySharingDetailsURL: userSettings.app.historySharingDetailsURL) historySharingDetailsURL: userSettings.app.historySharingDetailsURL)
super.init(initialViewState: userSession.userHooks.securityAndPrivacyScreenHook.update(viewState, homeserver: clientProxy.homeserver)) super.init(initialViewState: userSession.userHooks.securityAndPrivacyScreenHook.update(viewState))
if let powerLevels = roomProxy.infoPublisher.value.powerLevels { if let powerLevels = roomProxy.infoPublisher.value.powerLevels {
setupPermissions(powerLevels: powerLevels) setupPermissions(powerLevels: powerLevels)
@@ -19,7 +19,7 @@ class OAuthAccountSettingsPresenter: NSObject {
private let redirectURL: URL private let redirectURL: URL
private let presentationAnchor: UIWindow private let presentationAnchor: UIWindow
private let appMediator: AppMediatorProtocol private let appMediator: AppMediatorProtocol
private let appHooks: AppHooks private let presenterHook: OAuthAccountSettingsPresenterHookProtocol
typealias Continuation = AsyncStream<Result<Void, OAuthError>>.Continuation typealias Continuation = AsyncStream<Result<Void, OAuthError>>.Continuation
private let continuation: Continuation? private let continuation: Continuation?
@@ -27,14 +27,13 @@ class OAuthAccountSettingsPresenter: NSObject {
init(accountURL: URL, init(accountURL: URL,
presentationAnchor: UIWindow, presentationAnchor: UIWindow,
appMediator: AppMediatorProtocol, appMediator: AppMediatorProtocol,
userSettings: UserSettings, userSession: UserSessionProtocol,
appHooks: AppHooks,
continuation: Continuation? = nil) { continuation: Continuation? = nil) {
self.accountURL = accountURL self.accountURL = accountURL
redirectURL = userSettings.app.oAuthRedirectURL redirectURL = userSession.userSettings.app.oAuthRedirectURL
self.presentationAnchor = presentationAnchor self.presentationAnchor = presentationAnchor
self.appMediator = appMediator self.appMediator = appMediator
self.appHooks = appHooks presenterHook = userSession.userHooks.oAuthAccountSettingsPresenterHook
self.continuation = continuation self.continuation = continuation
super.init() super.init()
@@ -42,7 +41,7 @@ class OAuthAccountSettingsPresenter: NSObject {
/// Presents a web authentication session for the supplied data. /// Presents a web authentication session for the supplied data.
func start() { func start() {
let accountURL = appHooks.oAuthPresenterHook.update(accountURL) let accountURL = presenterHook.update(accountURL)
let session = ASWebAuthenticationSession(url: accountURL, callback: .oAuthRedirectURL(redirectURL)) { [continuation] _, error in let session = ASWebAuthenticationSession(url: accountURL, callback: .oAuthRedirectURL(redirectURL)) { [continuation] _, error in
guard let continuation else { return } guard let continuation else { return }
@@ -23,9 +23,9 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
actionsSubject.eraseToAnyPublisher() actionsSubject.eraseToAnyPublisher()
} }
init(appSettings: AppSettings, appHooks: AppHooks, clientProxy: ClientProxyProtocol?) { init(appSettings: AppSettings, screenHook: DeveloperOptionsScreenHookProtocol, clientProxy: ClientProxyProtocol?) {
viewModel = DeveloperOptionsScreenViewModel(developerOptions: appSettings, viewModel = DeveloperOptionsScreenViewModel(developerOptions: appSettings,
appHooks: appHooks, screenHook: screenHook,
clientProxy: clientProxy) clientProxy: clientProxy)
viewModel.actions viewModel.actions
@@ -14,9 +14,8 @@ enum DeveloperOptionsScreenViewModelAction {
} }
struct DeveloperOptionsScreenViewState: BindableState { struct DeveloperOptionsScreenViewState: BindableState {
let appHooks: AppHooks let screenHook: DeveloperOptionsScreenHookProtocol
var storeSizes: [StoreSize]? var storeSizes: [StoreSize]?
let shouldShowClearCache: Bool
let isSignedIn: Bool let isSignedIn: Bool
var bindings: DeveloperOptionsScreenViewStateBindings var bindings: DeveloperOptionsScreenViewStateBindings
@@ -20,10 +20,9 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
private let clientProxy: ClientProxyProtocol? private let clientProxy: ClientProxyProtocol?
init(developerOptions: DeveloperOptionsProtocol, appHooks: AppHooks, clientProxy: ClientProxyProtocol?) { init(developerOptions: DeveloperOptionsProtocol, screenHook: DeveloperOptionsScreenHookProtocol, clientProxy: ClientProxyProtocol?) {
self.clientProxy = clientProxy self.clientProxy = clientProxy
super.init(initialViewState: .init(appHooks: appHooks, super.init(initialViewState: .init(screenHook: screenHook,
shouldShowClearCache: clientProxy != nil,
isSignedIn: clientProxy != nil, isSignedIn: clientProxy != nil,
bindings: .init(developerOptions: developerOptions))) bindings: .init(developerOptions: developerOptions)))
@@ -54,9 +54,7 @@ struct DeveloperOptionsScreen: View {
Text("Moves search to a separate tab") Text("Moves search to a separate tab")
} }
context.viewState.appHooks context.viewState.screenHook.generalSectionRows()
.developerOptionsScreenHook
.generalSectionRows(isSignedIn: context.viewState.isSignedIn)
} }
Section("Accounts") { Section("Accounts") {
@@ -173,7 +171,7 @@ struct DeveloperOptionsScreen: View {
} }
} }
if context.viewState.shouldShowClearCache { if context.viewState.isSignedIn {
Section { Section {
Button(role: .destructive) { Button(role: .destructive) {
context.send(viewAction: .clearCache) context.send(viewAction: .clearCache)
@@ -257,7 +255,7 @@ private extension Set<TraceLogPack> {
struct DeveloperOptionsScreen_Previews: PreviewProvider { struct DeveloperOptionsScreen_Previews: PreviewProvider {
static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: AppSettings.volatile(), static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: AppSettings.volatile(),
appHooks: AppHooks(), screenHook: DefaultDeveloperOptionsScreenHook(),
clientProxy: ClientProxyMock(.init())) clientProxy: ClientProxyMock(.init()))
static var previews: some View { static var previews: some View {
@@ -123,7 +123,7 @@ class AuthenticationService: AuthenticationServiceProtocol {
loginHint: loginHint, loginHint: loginHint,
deviceId: nil, deviceId: nil,
additionalScopes: nil) additionalScopes: nil)
return .success(OAuthAuthorizationDataProxy(underlyingData: oAuthData)) return .success(OAuthAuthorizationDataProxy(underlyingData: oAuthData, homeserver: client.homeserver()))
} catch { } catch {
MXLog.error("Failed to get URL for OAuth login: \(error)") MXLog.error("Failed to get URL for OAuth login: \(error)")
return .failure(.oAuthError(.urlFailure)) return .failure(.oAuthError(.urlFailure))
@@ -85,7 +85,10 @@ enum OAuthError: Error {
} }
struct OAuthAuthorizationDataProxy: Hashable { struct OAuthAuthorizationDataProxy: Hashable {
/// The authorisation data supplied by the SDK.
let underlyingData: OAuthAuthorizationData let underlyingData: OAuthAuthorizationData
/// The homeserver that the authorisation is for.
let homeserver: String
var url: URL { var url: URL {
guard let url = URL(string: underlyingData.loginUrl()) else { guard let url = URL(string: underlyingData.loginUrl()) else {
@@ -634,7 +634,6 @@ class MockScreen: Identifiable {
emojiProvider: EmojiProvider(userSettings: userSession.userSettings), emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: appMediator, appMediator: appMediator,
appHooks: AppHooks(),
analytics: analytics, analytics: analytics,
userIndicatorController: UserIndicatorControllerMock(), userIndicatorController: UserIndicatorControllerMock(),
stateMachineFactory: StateMachineFactory())) stateMachineFactory: StateMachineFactory()))
@@ -686,7 +685,6 @@ class MockScreen: Identifiable {
emojiProvider: EmojiProvider(userSettings: userSession.userSettings), emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: AppMediatorMock(.init()), appMediator: AppMediatorMock(.init()),
appHooks: AppHooks(),
analytics: analytics, analytics: analytics,
userIndicatorController: UserIndicatorControllerMock(), userIndicatorController: UserIndicatorControllerMock(),
stateMachineFactory: StateMachineFactory())) stateMachineFactory: StateMachineFactory()))
@@ -743,7 +741,6 @@ class MockScreen: Identifiable {
let coordinator = EncryptionResetFlowCoordinator(parameters: .init(userSession: userSession, let coordinator = EncryptionResetFlowCoordinator(parameters: .init(userSession: userSession,
appMediator: AppMediatorMock(.init()), appMediator: AppMediatorMock(.init()),
appHooks: AppHooks(),
userIndicatorController: userIndicatorController, userIndicatorController: userIndicatorController,
navigationStackCoordinator: navigationStackCoordinator, navigationStackCoordinator: navigationStackCoordinator,
windowManger: windowManager)) windowManger: windowManager))
@@ -785,7 +782,6 @@ class MockScreen: Identifiable {
emojiProvider: EmojiProvider(userSettings: userSession.userSettings), emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: AppMediatorMock(.init()), appMediator: AppMediatorMock(.init()),
appHooks: AppHooks(),
analytics: analytics, analytics: analytics,
userIndicatorController: UserIndicatorControllerMock(), userIndicatorController: UserIndicatorControllerMock(),
stateMachineFactory: StateMachineFactory())) stateMachineFactory: StateMachineFactory()))
@@ -841,7 +837,6 @@ class MockScreen: Identifiable {
emojiProvider: EmojiProvider(userSettings: userSession.userSettings), emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: AppMediatorMock(.init()), appMediator: AppMediatorMock(.init()),
appHooks: AppHooks(),
analytics: analytics, analytics: analytics,
userIndicatorController: UserIndicatorControllerMock(), userIndicatorController: UserIndicatorControllerMock(),
stateMachineFactory: StateMachineFactory())) stateMachineFactory: StateMachineFactory()))
@@ -45,7 +45,6 @@ struct ChatsTabFlowCoordinatorTests {
emojiProvider: EmojiProvider(userSettings: userSession.userSettings), emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: AppMediatorMock(.init()), appMediator: AppMediatorMock(.init()),
appHooks: AppHooks(),
analytics: AnalyticsServiceMock(.init()), analytics: AnalyticsServiceMock(.init()),
userIndicatorController: UserIndicatorControllerMock(), userIndicatorController: UserIndicatorControllerMock(),
stateMachineFactory: stateMachineFactory) stateMachineFactory: stateMachineFactory)
@@ -531,7 +531,6 @@ final class RoomFlowCoordinatorTests {
emojiProvider: EmojiProvider(userSettings: userSettings), emojiProvider: EmojiProvider(userSettings: userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: AppMediatorMock(.init()), appMediator: AppMediatorMock(.init()),
appHooks: AppHooks(),
analytics: AnalyticsServiceMock(.init()), analytics: AnalyticsServiceMock(.init()),
userIndicatorController: UserIndicatorControllerMock(), userIndicatorController: UserIndicatorControllerMock(),
stateMachineFactory: StateMachineFactory()) stateMachineFactory: StateMachineFactory())
@@ -61,7 +61,6 @@ struct RoomMembersFlowCoordinatorTests {
emojiProvider: EmojiProvider(userSettings: userSession.userSettings), emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: AppMediatorMock(.init()), appMediator: AppMediatorMock(.init()),
appHooks: AppHooks(),
analytics: AnalyticsServiceMock(.init()), analytics: AnalyticsServiceMock(.init()),
userIndicatorController: UserIndicatorControllerMock(), userIndicatorController: UserIndicatorControllerMock(),
stateMachineFactory: stateMachineFactory) stateMachineFactory: stateMachineFactory)
@@ -58,7 +58,6 @@ struct UserSessionFlowCoordinatorTests {
emojiProvider: EmojiProvider(userSettings: userSession.userSettings), emojiProvider: EmojiProvider(userSettings: userSession.userSettings),
linkMetadataProvider: LinkMetadataProvider(), linkMetadataProvider: LinkMetadataProvider(),
appMediator: appMediator, appMediator: appMediator,
appHooks: AppHooks(),
analytics: AnalyticsServiceMock(.init()), analytics: AnalyticsServiceMock(.init()),
userIndicatorController: userIndicatorController, userIndicatorController: userIndicatorController,
stateMachineFactory: stateMachineFactory) stateMachineFactory: stateMachineFactory)