From 5a5f766c5da50ba3503245daaa3c0d14c65f8717 Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 2 Jul 2024 08:58:28 +0100 Subject: [PATCH] Rebase on SDK update. --- .../CallScreen/CallScreenViewModel.swift | 4 ++-- .../DeveloperOptionsScreenCoordinator.swift | 3 ++- .../DeveloperOptionsScreenModels.swift | 2 +- .../DeveloperOptionsScreenViewModel.swift | 4 ++-- .../View/DeveloperOptionsScreen.swift | 11 ++++------- .../Services/Client/ElementWellKnown.swift | 17 +++++------------ 6 files changed, 16 insertions(+), 25 deletions(-) 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) } }