Implement support for ElementCall through Rust side widgets (#1906)

* Implement support for ElementCall through Rust side widgets

* Add Element Call feature flag

* Fix the unit tests

* Address PR comments
This commit is contained in:
Stefan Ceriu
2023-10-17 12:41:56 +03:00
committed by GitHub
parent 524e4b3f1e
commit 6e8dff2ef6
25 changed files with 1059 additions and 18 deletions
@@ -22,6 +22,20 @@ import UserNotifications
enum RoomFlowCoordinatorAction: Equatable {
case presentedRoom(String)
case dismissedRoom
case presentCallScreen(roomProxy: RoomProxyProtocol)
static func == (lhs: RoomFlowCoordinatorAction, rhs: RoomFlowCoordinatorAction) -> Bool {
switch (lhs, rhs) {
case (.presentedRoom(let lhsRoomID), .presentedRoom(let rhsRoomID)):
return lhsRoomID == rhsRoomID
case (.dismissedRoom, .dismissedRoom):
return true
case (.presentCallScreen(let lhsRoomProxy), .presentCallScreen(let rhsRoomProxy)):
return lhsRoomProxy.id == rhsRoomProxy.id
default:
return false
}
}
}
class RoomFlowCoordinator: FlowCoordinatorProtocol {
@@ -372,6 +386,12 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.presentRoomMemberDetails(member: .init(value: member)))
case .presentMessageForwarding(let itemID):
stateMachine.tryEvent(.presentMessageForwarding(itemID: itemID))
case .presentCallScreen:
guard let roomProxy = self.roomProxy else {
fatalError()
}
actionsSubject.send(.presentCallScreen(roomProxy: roomProxy))
}
}
.store(in: &cancellables)
@@ -85,6 +85,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
case .dismissedRoom:
stateMachine.processEvent(.deselectRoom)
analytics.signpost.endRoomFlow()
case .presentCallScreen(let roomProxy):
presentCallScreen(roomProxy: roomProxy)
}
}
.store(in: &cancellables)
@@ -453,4 +455,23 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
self?.stateMachine.processEvent(.closedInvitesScreen)
}
}
// MARK: Calls
private func presentCallScreen(roomProxy: RoomProxyProtocol) {
let callScreenCoordinator = CallScreenCoordinator(parameters: .init(roomProxy: roomProxy,
callBaseURL: appSettings.elementCallBaseURL,
clientID: InfoPlistReader.main.bundleIdentifier))
callScreenCoordinator.actions
.sink { [weak self] action in
switch action {
case .dismiss:
self?.navigationSplitCoordinator.setSheetCoordinator(nil)
}
}
.store(in: &cancellables)
navigationSplitCoordinator.setSheetCoordinator(callScreenCoordinator, animated: true)
}
}