From c96102e69cdfe3bc93cc0038128b79e1be751038 Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 2 Jul 2024 08:58:28 +0100 Subject: [PATCH] Rebase on SDK update. --- ElementX.xcodeproj/project.pbxproj | 4 ++++ .../CallScreen/CallScreenViewModel.swift | 4 ++-- .../DeveloperOptionsScreenCoordinator.swift | 3 ++- .../DeveloperOptionsScreenModels.swift | 2 +- .../DeveloperOptionsScreenViewModel.swift | 4 ++-- .../View/DeveloperOptionsScreen.swift | 11 ++++------- .../Services/Client/ElementWellKnown.swift | 17 +++++------------ 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index d2bdf853f7..05945acfc3 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -264,6 +264,7 @@ 3F2148F11164C7C5609984EB /* GZIP in Frameworks */ = {isa = PBXBuildFile; productRef = 2B788C81F6369D164ADEB917 /* GZIP */; }; 3F327A62D233933F54F0F33A /* SwiftOGG in Frameworks */ = {isa = PBXBuildFile; productRef = 3FE40E79C36E7903121E6E3B /* SwiftOGG */; }; 3F70E237CE4C3FAB02FC227F /* NotificationConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C830A64609CBD152F06E0457 /* NotificationConstants.swift */; }; + 3F997171C3C79A45E92BF9EF /* ElementWellKnown.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FAC366FF299BCC555D756E /* ElementWellKnown.swift */; }; 401BB28CD6B7DD6B4E7863E7 /* ServerConfirmationScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9342F5D6729627B6393AF853 /* ServerConfirmationScreenModels.swift */; }; 407DCE030E0F9B7C9861D38A /* LRUCache in Frameworks */ = {isa = PBXBuildFile; productRef = 1081D3630AAD3ACEDDEC3A98 /* LRUCache */; }; 40B79D20A873620F7F128A2C /* UserPreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35FA991289149D31F4286747 /* UserPreference.swift */; }; @@ -1621,6 +1622,7 @@ 78913D6E120D46138E97C107 /* NavigationSplitCoordinatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationSplitCoordinatorTests.swift; sourceTree = ""; }; 7893780A1FD6E3F38B3E9049 /* UserIndicatorControllerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserIndicatorControllerMock.swift; sourceTree = ""; }; 796CBD0C56FA0D3AEDAB255B /* SessionVerificationScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionVerificationScreenCoordinator.swift; sourceTree = ""; }; + 79FAC366FF299BCC555D756E /* ElementWellKnown.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementWellKnown.swift; sourceTree = ""; }; 7A03E073077D92AA19C43DCF /* IdentityConfirmationScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityConfirmationScreenCoordinator.swift; sourceTree = ""; }; 7A5D2323D7B6BF4913EB7EED /* landscape_test_image.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = landscape_test_image.jpg; sourceTree = ""; }; 7AAD8C633AA57948B34EDCF7 /* RoomChangeRolesScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomChangeRolesScreenViewModelProtocol.swift; sourceTree = ""; }; @@ -3862,6 +3864,7 @@ D09A267106B9585D3D0CFC0D /* ClientError.swift */, 18F2958E6D247AE2516BEEE8 /* ClientProxy.swift */, 6033779EB37259F27F938937 /* ClientProxyProtocol.swift */, + 79FAC366FF299BCC555D756E /* ElementWellKnown.swift */, ); path = Client; sourceTree = ""; @@ -6060,6 +6063,7 @@ 48416BBEB8DDF3E4DED0EDB6 /* ElementCallServiceProtocol.swift in Sources */, 07CC13C5729C24255348CBBD /* ElementCallWidgetDriver.swift in Sources */, 370AF5BFCD4384DD455479B6 /* ElementCallWidgetDriverProtocol.swift in Sources */, + 3F997171C3C79A45E92BF9EF /* ElementWellKnown.swift in Sources */, 7C1A7B594B2F8143F0DD0005 /* ElementXAttributeScope.swift in Sources */, 7361B011A79BF723D8C9782B /* EmojiCategory.swift in Sources */, E45C9FA22BC13B477FD3B4AC /* EmojiDetection.swift in Sources */, diff --git a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift index 2bc91fa676..6086449eb9 100644 --- a/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift +++ b/ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift @@ -94,8 +94,8 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol Task { let baseURL = if let elementCallBaseURLOverride { elementCallBaseURLOverride - } else if case .success(let wellKnown) = await clientProxy.getElementWellKnown(), let wellKnownCallWidgetURL = wellKnown?.call?.widgetURL { - wellKnownCallWidgetURL + } else if case .success(let wellKnown) = await clientProxy.getElementWellKnown(), let wellKnownCall = wellKnown?.call { + wellKnownCall.widgetURL } else { elementCallBaseURL } diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenCoordinator.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenCoordinator.swift index 28d11c608c..1b4d9061c8 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenCoordinator.swift @@ -32,7 +32,8 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol { } init() { - viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings) + viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings, + elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL) viewModel.actions .sink { [weak self] action in diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift index f0f1204a0e..ff80493fa4 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift @@ -21,6 +21,7 @@ enum DeveloperOptionsScreenViewModelAction { } struct DeveloperOptionsScreenViewState: BindableState { + let elementCallBaseURL: URL var bindings: DeveloperOptionsScreenViewStateBindings } @@ -46,7 +47,6 @@ enum DeveloperOptionsScreenViewAction { protocol DeveloperOptionsProtocol: AnyObject { var logLevel: TracingConfiguration.LogLevel { get set } var hideUnreadMessagesBadge: Bool { get set } - var elementCallBaseURL: URL { get set } var elementCallBaseURLOverride: URL? { get set } var fuzzyRoomListSearchEnabled: Bool { get set } } diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenViewModel.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenViewModel.swift index 57292aee40..7d218a5308 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenViewModel.swift @@ -26,9 +26,9 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve actionsSubject.eraseToAnyPublisher() } - init(developerOptions: DeveloperOptionsProtocol) { + init(developerOptions: DeveloperOptionsProtocol, elementCallBaseURL: URL) { let bindings = DeveloperOptionsScreenViewStateBindings(developerOptions: developerOptions) - let state = DeveloperOptionsScreenViewState(bindings: bindings) + let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, bindings: bindings) super.init(initialViewState: state) } diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift index a27ae31121..e79e114b5f 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift @@ -38,14 +38,10 @@ struct DeveloperOptionsScreen: View { } Section("Element Call") { - TextField(context.elementCallBaseURL?.absoluteString ?? elementCallBaseURLOverride?.absoluteString, - text: $elementCallBaseURLString) + TextField(context.viewState.elementCallBaseURL.absoluteString, text: $elementCallBaseURLString) .submitLabel(.done) .onSubmit { - guard let url = URL(string: elementCallBaseURLString) else { - return - } - + guard let url = URL(string: elementCallBaseURLString) else { return } context.elementCallBaseURLOverride = url } .autocorrectionDisabled(true) @@ -149,7 +145,8 @@ private struct LogLevelConfigurationView: View { // MARK: - Previews struct DeveloperOptionsScreen_Previews: PreviewProvider { - static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings) + static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings, + elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL) static var previews: some View { NavigationStack { DeveloperOptionsScreen(context: viewModel.context) diff --git a/ElementX/Sources/Services/Client/ElementWellKnown.swift b/ElementX/Sources/Services/Client/ElementWellKnown.swift index 044fe6ee2e..c65e0090b2 100644 --- a/ElementX/Sources/Services/Client/ElementWellKnown.swift +++ b/ElementX/Sources/Services/Client/ElementWellKnown.swift @@ -19,24 +19,17 @@ import MatrixRustSDK struct ElementWellKnown { struct Call { - let widgetURL: URL? + let widgetURL: URL - init?(_ wellKnown: MatrixRustSDK.ElementCallWellKnown?) { - guard let wellKnown else { - return nil - } - - widgetURL = URL(string: wellKnown.widgetUrl) + init?(_ wellKnown: MatrixRustSDK.ElementCallWellKnown) { + guard let widgetURL = URL(string: wellKnown.widgetUrl) else { return nil } + self.widgetURL = widgetURL } } let call: Call? - init?(_ wellKnown: MatrixRustSDK.ElementWellKnown?) { - guard let wellKnown else { - return nil - } - + init?(_ wellKnown: MatrixRustSDK.ElementWellKnown) { call = Call(wellKnown.call) } }