diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index bb7b8f9ec..95698100b 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -7332,7 +7332,7 @@ repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = 1.1.62; + version = 1.1.63; }; }; 821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 088c6704b..cc28bb59a 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -139,8 +139,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matrix-org/matrix-rust-components-swift", "state" : { - "revision" : "c060a2a24f3cfa3cff3f6075bdc1e88abea72553", - "version" : "1.1.62" + "revision" : "3d116223646fc7310b977e5116f96b834a9f57f6", + "version" : "1.1.63" } }, { diff --git a/ElementX/Sources/FlowCoordinators/SettingsFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/SettingsFlowCoordinator.swift index c6e97f42f..269da0a72 100644 --- a/ElementX/Sources/FlowCoordinators/SettingsFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/SettingsFlowCoordinator.swift @@ -113,8 +113,8 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { presentSecureBackupScreen(animated: true) case .userDetails: presentUserDetailsEditScreen() - case .accountProfile: - presentAccountProfileURL() + case let .manageAccount(url): + presentAccountManagementURL(url) case .analytics: presentAnalyticsScreen() case .appLock: @@ -130,8 +130,6 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { presentLegalInformationScreen() case .blockedUsers: presentBlockedUsersScreen() - case .accountSessions: - presentAccountSessionsListURL() case .notifications: presentNotificationSettings() case .advancedSettings: @@ -242,23 +240,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol { } // MARK: OIDC Account Management - - private func presentAccountProfileURL() { - guard let url = parameters.userSession.clientProxy.accountURL(action: .profile) else { - MXLog.error("Account URL is missing.") - return - } - presentAccountManagementURL(url) - } - - private func presentAccountSessionsListURL() { - guard let url = parameters.userSession.clientProxy.accountURL(action: .sessionsList) else { - MXLog.error("Account URL is missing.") - return - } - presentAccountManagementURL(url) - } - + private var accountSettingsPresenter: OIDCAccountSettingsPresenter? 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. diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index bf8de25ee..a7ae2e0f1 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -2104,14 +2104,14 @@ class ClientProxyMock: ClientProxyProtocol { } } } - var accountURLActionClosure: ((AccountManagementAction) -> URL?)? + var accountURLActionClosure: ((AccountManagementAction) async -> URL?)? - func accountURL(action: AccountManagementAction) -> URL? { + func accountURL(action: AccountManagementAction) async -> URL? { accountURLActionCallsCount += 1 accountURLActionReceivedAction = action accountURLActionReceivedInvocations.append(action) if let accountURLActionClosure = accountURLActionClosure { - return accountURLActionClosure(action) + return await accountURLActionClosure(action) } else { return accountURLActionReturnValue } diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index f6a521f7f..b33b58eba 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -135,9 +135,9 @@ class SDKClientMock: SDKClientProtocol { } } } - public var accountUrlActionClosure: ((AccountManagementAction?) throws -> String?)? + public var accountUrlActionClosure: ((AccountManagementAction?) async throws -> String?)? - public func accountUrl(action: AccountManagementAction?) throws -> String? { + public func accountUrl(action: AccountManagementAction?) async throws -> String? { if let error = accountUrlActionThrowableError { throw error } @@ -145,7 +145,7 @@ class SDKClientMock: SDKClientProtocol { accountUrlActionReceivedAction = action accountUrlActionReceivedInvocations.append(action) if let accountUrlActionClosure = accountUrlActionClosure { - return try accountUrlActionClosure(action) + return try await accountUrlActionClosure(action) } else { return accountUrlActionReturnValue } diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenCoordinator.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenCoordinator.swift index 5a74d2fbd..ad0787249 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenCoordinator.swift @@ -27,13 +27,12 @@ enum SettingsScreenCoordinatorAction { case logout case secureBackup case userDetails - case accountProfile case analytics case appLock case bugReport case about case blockedUsers - case accountSessions + case manageAccount(url: URL) case notifications case advancedSettings case developerOptions @@ -64,8 +63,8 @@ final class SettingsScreenCoordinator: CoordinatorProtocol { actionsSubject.send(.dismiss) case .userDetails: actionsSubject.send(.userDetails) - case .accountProfile: - actionsSubject.send(.accountProfile) + case let .manageAccount(url): + actionsSubject.send(.manageAccount(url: url)) case .analytics: actionsSubject.send(.analytics) case .appLock: @@ -78,8 +77,6 @@ final class SettingsScreenCoordinator: CoordinatorProtocol { actionsSubject.send(.blockedUsers) case .secureBackup: actionsSubject.send(.secureBackup) - case .accountSessionsList: - actionsSubject.send(.accountSessions) case .notifications: actionsSubject.send(.notifications) case .advancedSettings: diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenModels.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenModels.swift index 1d0d51e4e..63ce7308e 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenModels.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenModels.swift @@ -17,17 +17,16 @@ import Foundation import UIKit -enum SettingsScreenViewModelAction { +enum SettingsScreenViewModelAction: Equatable { case close case userDetails - case accountProfile + case manageAccount(url: URL) case analytics case appLock case reportBug case about case blockedUsers case secureBackup - case accountSessionsList case notifications case advancedSettings case developerOptions @@ -57,14 +56,13 @@ struct SettingsScreenViewState: BindableState { enum SettingsScreenViewAction { case close case userDetails - case accountProfile case analytics case appLock case reportBug case about case blockedUsers case secureBackup - case accountSessionsList + case manageAccount(url: URL) case notifications case developerOptions case advancedSettings diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift index ebf0ffded..03baadbc2 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/SettingsScreenViewModel.swift @@ -29,8 +29,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo init(userSession: UserSessionProtocol, appSettings: AppSettings) { super.init(initialViewState: .init(deviceID: userSession.deviceID, userID: userSession.userID, - accountProfileURL: userSession.clientProxy.accountURL(action: .profile), - accountSessionsListURL: userSession.clientProxy.accountURL(action: .sessionsList), showDeveloperOptions: appSettings.isDevelopmentBuild), imageProvider: userSession.mediaProvider) @@ -81,6 +79,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo Task { await userSession.clientProxy.loadUserAvatarURL() await userSession.clientProxy.loadUserDisplayName() + await state.accountProfileURL = userSession.clientProxy.accountURL(action: .profile) + await state.accountSessionsListURL = userSession.clientProxy.accountURL(action: .sessionsList) } } @@ -90,8 +90,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo actionsSubject.send(.close) case .userDetails: actionsSubject.send(.userDetails) - case .accountProfile: - actionsSubject.send(.accountProfile) + case let .manageAccount(url): + actionsSubject.send(.manageAccount(url: url)) case .analytics: actionsSubject.send(.analytics) case .appLock: @@ -108,8 +108,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo actionsSubject.send(.secureBackup) case .notifications: actionsSubject.send(.notifications) - case .accountSessionsList: - actionsSubject.send(.accountSessionsList) case .advancedSettings: actionsSubject.send(.advancedSettings) case .developerOptions: diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift index 6fa81c9aa..fc09d4675 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift @@ -29,9 +29,7 @@ struct SettingsScreen: View { mainSection - if context.viewState.accountSessionsListURL != nil { - manageSessionsSection - } + manageSessionsSection advancedOptionsSection @@ -95,11 +93,11 @@ struct SettingsScreen: View { private var mainSection: some View { Section { - if context.viewState.accountProfileURL != nil { + if let url = context.viewState.accountProfileURL { ListRow(label: .default(title: L10n.actionManageAccount, icon: \.userProfile), kind: .button { - context.send(viewAction: .accountProfile) + context.send(viewAction: .manageAccount(url: url)) }) .accessibilityIdentifier(A11yIdentifiers.settingsScreen.account) } @@ -150,13 +148,16 @@ struct SettingsScreen: View { } } + @ViewBuilder private var manageSessionsSection: some View { - Section { - ListRow(label: .default(title: L10n.actionManageDevices, - icon: \.devices), - kind: .button { - context.send(viewAction: .accountSessionsList) - }) + if let url = context.viewState.accountSessionsListURL { + Section { + ListRow(label: .default(title: L10n.actionManageDevices, + icon: \.devices), + kind: .button { + context.send(viewAction: .manageAccount(url: url)) + }) + } } } @@ -252,6 +253,7 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview { static var previews: some View { NavigationStack { SettingsScreen(context: viewModel.context) + .snapshot(delay: 1.0) } } } diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 82beba59a..c9feef911 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -281,8 +281,8 @@ class ClientProxy: ClientProxyProtocol { } } - func accountURL(action: AccountManagementAction) -> URL? { - try? client.accountUrl(action: action).flatMap(URL.init(string:)) + func accountURL(action: AccountManagementAction) async -> URL? { + try? await client.accountUrl(action: action).flatMap(URL.init(string:)) } func createDirectRoomIfNeeded(with userID: String, expectedRoomName: String?) async -> Result<(roomID: String, isNewRoom: Bool), ClientProxyError> { diff --git a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift index 3d91a74eb..7acdca61b 100644 --- a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift @@ -121,7 +121,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol { func stopSync() - func accountURL(action: AccountManagementAction) -> URL? + func accountURL(action: AccountManagementAction) async -> URL? func createDirectRoomIfNeeded(with userID: String, expectedRoomName: String?) async -> Result<(roomID: String, isNewRoom: Bool), ClientProxyError> diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPad-en-GB.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPad-en-GB.1.png index 5a74ed168..f5a4414c4 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPad-en-GB.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPad-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b8d548c95a888ab8feb15497036af3c89895723dd9525e7681b77761c0347d70 -size 197781 +oid sha256:42c6c41d8e7cedc083dda31f83603bb3afdc827454f12dffff2262b6a66809fb +size 211546 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPad-pseudo.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPad-pseudo.1.png index 68774d3d3..6ef30e5e9 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPad-pseudo.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPad-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:de12cfef26e495bcf88a206f9fe9d23cd69f3272b5ae142650e7b77c6f894ef0 -size 267624 +oid sha256:708a96b3352fc118715a9cd92369eaf5130aa2dbfdd41a5a122ef44d28becd93 +size 282736 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPhone-15-en-GB.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPhone-15-en-GB.1.png index 311fa61b5..b674cd8bc 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPhone-15-en-GB.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPhone-15-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94f2d6b19bd5fbb45cd4edf50944337d512a93c9aec31ec9fad0ec0168d62fe0 -size 141417 +oid sha256:57d1dc985ee32ac33b689281ff6869c21e1cc97c4f3a1bb5c9c84dd3ea0f3010 +size 143141 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPhone-15-pseudo.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPhone-15-pseudo.1.png index 07e79a926..9cc0bac79 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPhone-15-pseudo.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_settingsScreen-iPhone-15-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b85fccd1487aa9f7b46b99d4ba3c9758d6b43bfecb6e4ff7ac3b7d407fdd2f5e -size 195200 +oid sha256:b27765cd80dd36afd157d672c254f9d2481e70ccd1faca0409b6d4a9b5c91979 +size 188558 diff --git a/project.yml b/project.yml index c0b8a67b0..eb8b4ea11 100644 --- a/project.yml +++ b/project.yml @@ -49,7 +49,7 @@ packages: # Element/Matrix dependencies MatrixRustSDK: url: https://github.com/matrix-org/matrix-rust-components-swift - exactVersion: 1.1.62 + exactVersion: 1.1.63 # path: ../matrix-rust-sdk Compound: url: https://github.com/element-hq/compound-ios