Base ElementCall encryption on the room encryption state, remove developer options setting

This commit is contained in:
Stefan Ceriu
2024-02-01 16:37:03 +02:00
committed by Stefan Ceriu
parent 497177ee65
commit 7aa81f542c
11 changed files with 25 additions and 37 deletions
@@ -23,8 +23,6 @@ struct CallScreenCoordinatorParameters {
let callBaseURL: URL
/// A way to identify the current client against Element Call
let clientID: String
/// Whether encryption should be used within the call
let useEncryption: Bool
}
enum CallScreenCoordinatorAction {
@@ -43,8 +41,7 @@ final class CallScreenCoordinator: CoordinatorProtocol {
init(parameters: CallScreenCoordinatorParameters) {
viewModel = CallScreenViewModel(roomProxy: parameters.roomProxy,
callBaseURL: parameters.callBaseURL,
clientID: parameters.clientID,
useEncryption: parameters.useEncryption)
clientID: parameters.clientID)
}
func start() {
@@ -48,8 +48,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
/// - clientID: Something to identify the current client on the Element Call side
init(roomProxy: RoomProxyProtocol,
callBaseURL: URL,
clientID: String,
useEncryption: Bool) {
clientID: String) {
self.roomProxy = roomProxy
widgetDriver = roomProxy.elementCallWidgetDriver()
@@ -98,7 +97,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
.store(in: &cancellables)
Task {
switch await widgetDriver.start(baseURL: callBaseURL, clientID: clientID, useEncryption: useEncryption) {
switch await widgetDriver.start(baseURL: callBaseURL, clientID: clientID) {
case .success(let url):
state.url = url
case .failure(let error):
@@ -163,14 +163,13 @@ struct CallScreen_Previews: PreviewProvider {
let widgetDriver = ElementCallWidgetDriverMock()
widgetDriver.underlyingMessagePublisher = .init()
widgetDriver.underlyingActions = PassthroughSubject<ElementCallWidgetDriverAction, Never>().eraseToAnyPublisher()
widgetDriver.startBaseURLClientIDUseEncryptionReturnValue = .success(URL.userDirectory)
widgetDriver.startBaseURLClientIDReturnValue = .success(URL.userDirectory)
roomProxy.elementCallWidgetDriverReturnValue = widgetDriver
return CallScreenViewModel(roomProxy: roomProxy,
callBaseURL: "https://call.element.io",
clientID: "io.element.elementx",
useEncryption: false)
clientID: "io.element.elementx")
}()
static var previews: some View {
@@ -53,7 +53,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
var roomListFiltersEnabled: Bool { get set }
var elementCallBaseURL: URL { get set }
var elementCallUseEncryption: Bool { get set }
}
extension AppSettings: DeveloperOptionsProtocol { }
@@ -75,10 +75,6 @@ struct DeveloperOptionsScreen: View {
.autocorrectionDisabled(true)
.autocapitalization(.none)
.foregroundColor(URL(string: elementCallBaseURLString) == nil ? .red : .primary)
Toggle(isOn: $context.elementCallUseEncryption) {
Text("Use encryption")
}
}
Section {