mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Expose Element Call settings in the developer options. Start using th… (#2039)
* Expose Element Call settings in the developer options. Start using the encryption widget parameter. * Remove the Element Call feature flag
This commit is contained in:
parent
b13abf9cdf
commit
5dcb24add7
@ -37,12 +37,14 @@ final class AppSettings {
|
||||
case viewSourceEnabled
|
||||
case richTextEditorEnabled
|
||||
|
||||
case elementCallBaseURL
|
||||
case elementCallEncryptionEnabled
|
||||
|
||||
// Feature flags
|
||||
case shouldCollapseRoomStateEvents
|
||||
case userSuggestionsEnabled
|
||||
case readReceiptsEnabled
|
||||
case swiftUITimelineEnabled
|
||||
case elementCallEnabled
|
||||
case chatBackupEnabled
|
||||
}
|
||||
|
||||
@ -215,7 +217,11 @@ final class AppSettings {
|
||||
|
||||
// MARK: - Element Call
|
||||
|
||||
let elementCallBaseURL: URL = "https://call.element.dev"
|
||||
@UserPreference(key: UserDefaultsKeys.elementCallBaseURL, defaultValue: "https://call.element.io", storageType: .userDefaults(store))
|
||||
var elementCallBaseURL: URL
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.elementCallEncryptionEnabled, defaultValue: true, storageType: .userDefaults(store))
|
||||
var elementCallUseEncryption
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
@ -267,9 +273,6 @@ final class AppSettings {
|
||||
@UserPreference(key: UserDefaultsKeys.swiftUITimelineEnabled, defaultValue: false, storageType: .volatile)
|
||||
var swiftUITimelineEnabled
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.elementCallEnabled, defaultValue: true, storageType: .userDefaults(store))
|
||||
var elementCallEnabled
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.chatBackupEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||
var chatBackupEnabled
|
||||
}
|
||||
|
@ -510,7 +510,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentCallScreen(roomProxy: RoomProxyProtocol) {
|
||||
let callScreenCoordinator = CallScreenCoordinator(parameters: .init(roomProxy: roomProxy,
|
||||
callBaseURL: appSettings.elementCallBaseURL,
|
||||
clientID: InfoPlistReader.main.bundleIdentifier))
|
||||
clientID: InfoPlistReader.main.bundleIdentifier,
|
||||
useEncryption: appSettings.elementCallUseEncryption))
|
||||
|
||||
callScreenCoordinator.actions
|
||||
.sink { [weak self] action in
|
||||
|
@ -723,23 +723,23 @@ class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol {
|
||||
|
||||
//MARK: - start
|
||||
|
||||
var startBaseURLClientIDCallsCount = 0
|
||||
var startBaseURLClientIDCalled: Bool {
|
||||
return startBaseURLClientIDCallsCount > 0
|
||||
var startBaseURLClientIDUseEncryptionCallsCount = 0
|
||||
var startBaseURLClientIDUseEncryptionCalled: Bool {
|
||||
return startBaseURLClientIDUseEncryptionCallsCount > 0
|
||||
}
|
||||
var startBaseURLClientIDReceivedArguments: (baseURL: URL, clientID: String)?
|
||||
var startBaseURLClientIDReceivedInvocations: [(baseURL: URL, clientID: String)] = []
|
||||
var startBaseURLClientIDReturnValue: Result<URL, ElementCallWidgetDriverError>!
|
||||
var startBaseURLClientIDClosure: ((URL, String) async -> Result<URL, ElementCallWidgetDriverError>)?
|
||||
var startBaseURLClientIDUseEncryptionReceivedArguments: (baseURL: URL, clientID: String, useEncryption: Bool)?
|
||||
var startBaseURLClientIDUseEncryptionReceivedInvocations: [(baseURL: URL, clientID: String, useEncryption: Bool)] = []
|
||||
var startBaseURLClientIDUseEncryptionReturnValue: Result<URL, ElementCallWidgetDriverError>!
|
||||
var startBaseURLClientIDUseEncryptionClosure: ((URL, String, Bool) async -> Result<URL, ElementCallWidgetDriverError>)?
|
||||
|
||||
func start(baseURL: URL, clientID: String) async -> Result<URL, ElementCallWidgetDriverError> {
|
||||
startBaseURLClientIDCallsCount += 1
|
||||
startBaseURLClientIDReceivedArguments = (baseURL: baseURL, clientID: clientID)
|
||||
startBaseURLClientIDReceivedInvocations.append((baseURL: baseURL, clientID: clientID))
|
||||
if let startBaseURLClientIDClosure = startBaseURLClientIDClosure {
|
||||
return await startBaseURLClientIDClosure(baseURL, clientID)
|
||||
func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result<URL, ElementCallWidgetDriverError> {
|
||||
startBaseURLClientIDUseEncryptionCallsCount += 1
|
||||
startBaseURLClientIDUseEncryptionReceivedArguments = (baseURL: baseURL, clientID: clientID, useEncryption: useEncryption)
|
||||
startBaseURLClientIDUseEncryptionReceivedInvocations.append((baseURL: baseURL, clientID: clientID, useEncryption: useEncryption))
|
||||
if let startBaseURLClientIDUseEncryptionClosure = startBaseURLClientIDUseEncryptionClosure {
|
||||
return await startBaseURLClientIDUseEncryptionClosure(baseURL, clientID, useEncryption)
|
||||
} else {
|
||||
return startBaseURLClientIDReturnValue
|
||||
return startBaseURLClientIDUseEncryptionReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - sendMessage
|
||||
|
@ -23,6 +23,8 @@ 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 {
|
||||
@ -44,7 +46,8 @@ final class CallScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
viewModel = CallScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
callBaseURL: parameters.callBaseURL,
|
||||
clientID: parameters.clientID)
|
||||
clientID: parameters.clientID,
|
||||
useEncryption: parameters.useEncryption)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
@ -46,7 +46,10 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
||||
/// - roomProxy: The room in which the call should be created
|
||||
/// - callBaseURL: Which Element Call instance should be used
|
||||
/// - clientID: Something to identify the current client on the Element Call side
|
||||
init(roomProxy: RoomProxyProtocol, callBaseURL: URL, clientID: String) {
|
||||
init(roomProxy: RoomProxyProtocol,
|
||||
callBaseURL: URL,
|
||||
clientID: String,
|
||||
useEncryption: Bool) {
|
||||
self.roomProxy = roomProxy
|
||||
self.callBaseURL = callBaseURL
|
||||
self.clientID = clientID
|
||||
@ -99,7 +102,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
||||
.store(in: &cancellables)
|
||||
|
||||
Task {
|
||||
switch await widgetDriver.start(baseURL: callBaseURL, clientID: clientID) {
|
||||
switch await widgetDriver.start(baseURL: callBaseURL, clientID: clientID, useEncryption: useEncryption) {
|
||||
case .success(let url):
|
||||
state.url = url
|
||||
case .failure(let error):
|
||||
|
@ -23,8 +23,6 @@ struct CallScreen: View {
|
||||
|
||||
var body: some View {
|
||||
WebView(url: context.viewState.url, viewModelContext: context)
|
||||
.navigationTitle("Call")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.ignoresSafeArea(edges: .bottom)
|
||||
.presentationDragIndicator(.visible)
|
||||
.environment(\.colorScheme, .dark)
|
||||
@ -164,13 +162,14 @@ struct CallScreen_Previews: PreviewProvider {
|
||||
let widgetDriver = ElementCallWidgetDriverMock()
|
||||
widgetDriver.underlyingMessagePublisher = .init()
|
||||
widgetDriver.underlyingActions = PassthroughSubject<ElementCallWidgetDriverAction, Never>().eraseToAnyPublisher()
|
||||
widgetDriver.startBaseURLClientIDReturnValue = .success(URL.userDirectory)
|
||||
widgetDriver.startBaseURLClientIDUseEncryptionReturnValue = .success(URL.userDirectory)
|
||||
|
||||
roomProxy.elementCallWidgetDriverReturnValue = widgetDriver
|
||||
|
||||
return CallScreenViewModel(roomProxy: roomProxy,
|
||||
callBaseURL: "https://call.element.io",
|
||||
clientID: "io.element.elementx")
|
||||
clientID: "io.element.elementx",
|
||||
useEncryption: false)
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
|
@ -116,7 +116,6 @@ struct RoomScreenViewState: BindableState {
|
||||
|
||||
var ownUserID: String
|
||||
|
||||
var showCallButton = false
|
||||
var isCallOngoing = false
|
||||
|
||||
var bindings: RoomScreenViewStateBindings
|
||||
|
@ -264,11 +264,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
appSettings.$readReceiptsEnabled
|
||||
.weakAssign(to: \.state.readReceiptsEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.$elementCallEnabled
|
||||
.weakAssign(to: \.state.showCallButton, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
|
||||
roomProxy.members
|
||||
.map { members in
|
||||
members.reduce(into: [String: RoomMemberState]()) { dictionary, member in
|
||||
|
@ -162,21 +162,19 @@ struct RoomScreen: View {
|
||||
|
||||
@ViewBuilder
|
||||
private var callButton: some View {
|
||||
if context.viewState.showCallButton {
|
||||
if context.viewState.isCallOngoing {
|
||||
Button {
|
||||
context.send(viewAction: .presentCall)
|
||||
} label: {
|
||||
Label(L10n.actionJoin, icon: \.videoCallSolid)
|
||||
.labelStyle(.titleAndIcon)
|
||||
}
|
||||
.buttonStyle(ElementCallButtonStyle())
|
||||
} else {
|
||||
Button {
|
||||
context.send(viewAction: .presentCall)
|
||||
} label: {
|
||||
CompoundIcon(\.videoCallSolid)
|
||||
}
|
||||
if context.viewState.isCallOngoing {
|
||||
Button {
|
||||
context.send(viewAction: .presentCall)
|
||||
} label: {
|
||||
Label(L10n.actionJoin, icon: \.videoCallSolid)
|
||||
.labelStyle(.titleAndIcon)
|
||||
}
|
||||
.buttonStyle(ElementCallButtonStyle())
|
||||
} else {
|
||||
Button {
|
||||
context.send(viewAction: .presentCall)
|
||||
} label: {
|
||||
CompoundIcon(\.videoCallSolid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,8 +49,10 @@ protocol DeveloperOptionsProtocol: AnyObject {
|
||||
var userSuggestionsEnabled: Bool { get set }
|
||||
var readReceiptsEnabled: Bool { get set }
|
||||
var swiftUITimelineEnabled: Bool { get set }
|
||||
var elementCallEnabled: Bool { get set }
|
||||
var chatBackupEnabled: Bool { get set }
|
||||
|
||||
var elementCallBaseURL: URL { get set }
|
||||
var elementCallUseEncryption: Bool { get set }
|
||||
}
|
||||
|
||||
extension AppSettings: DeveloperOptionsProtocol { }
|
||||
|
@ -19,6 +19,7 @@ import SwiftUI
|
||||
struct DeveloperOptionsScreen: View {
|
||||
@ObservedObject var context: DeveloperOptionsScreenViewModel.Context
|
||||
@State private var showConfetti = false
|
||||
@State private var elementCallBaseURLString = ""
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
@ -52,10 +53,6 @@ struct DeveloperOptionsScreen: View {
|
||||
Text("SwiftUI Timeline")
|
||||
Text("Resets on reboot")
|
||||
}
|
||||
|
||||
Toggle(isOn: $context.elementCallEnabled) {
|
||||
Text("Element Call")
|
||||
}
|
||||
}
|
||||
|
||||
Section("Room creation") {
|
||||
@ -63,6 +60,25 @@ struct DeveloperOptionsScreen: View {
|
||||
Text("User suggestions")
|
||||
}
|
||||
}
|
||||
|
||||
Section("Element Call") {
|
||||
TextField(context.elementCallBaseURL.absoluteString, text: $elementCallBaseURLString)
|
||||
.submitLabel(.done)
|
||||
.onSubmit {
|
||||
guard let url = URL(string: elementCallBaseURLString) else {
|
||||
return
|
||||
}
|
||||
|
||||
context.elementCallBaseURL = url
|
||||
}
|
||||
.autocorrectionDisabled(true)
|
||||
.autocapitalization(.none)
|
||||
.foregroundColor(URL(string: elementCallBaseURLString) == nil ? .red : .primary)
|
||||
|
||||
Toggle(isOn: $context.elementCallUseEncryption) {
|
||||
Text("Use encryption")
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
Button {
|
||||
|
@ -52,7 +52,7 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
|
||||
self.room = room
|
||||
}
|
||||
|
||||
func start(baseURL: URL, clientID: String) async -> Result<URL, ElementCallWidgetDriverError> {
|
||||
func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result<URL, ElementCallWidgetDriverError> {
|
||||
guard let room = room as? Room else {
|
||||
return .failure(.roomInvalid)
|
||||
}
|
||||
@ -68,7 +68,7 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
|
||||
confineToRoom: true,
|
||||
font: nil,
|
||||
analyticsId: nil,
|
||||
encryption: .unencrypted)) else {
|
||||
encryption: useEncryption ? .perParticipantKeys : .unencrypted)) else {
|
||||
return .failure(.failedBuildingWidgetSettings)
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ protocol ElementCallWidgetDriverProtocol {
|
||||
var messagePublisher: PassthroughSubject<String, Never> { get }
|
||||
var actions: AnyPublisher<ElementCallWidgetDriverAction, Never> { get }
|
||||
|
||||
func start(baseURL: URL, clientID: String) async -> Result<URL, ElementCallWidgetDriverError>
|
||||
func start(baseURL: URL, clientID: String, useEncryption: Bool) async -> Result<URL, ElementCallWidgetDriverError>
|
||||
|
||||
func sendMessage(_ message: String) async -> Result<Bool, ElementCallWidgetDriverError>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user