Support for ongoing voice vs video call + joining (#5399)

This commit is contained in:
Valere Fedronic
2026-04-21 11:11:52 +02:00
committed by GitHub
parent d9013208dd
commit d49a6e5a5d
31 changed files with 185 additions and 54 deletions
@@ -7,7 +7,6 @@
//
import Foundation
import MatrixRustSDK
import OrderedCollections
enum RoomScreenViewModelAction: Equatable {
@@ -60,6 +59,8 @@ struct RoomScreenViewState: BindableState {
var canJoinCall = false
/// Whether or not this room currently has a call in progress.
var hasOngoingCall: Bool
/// The ongoing call nature (audio or video), null if not advertised by the participants
var activeRoomCallIntent: CallIntent?
/// Whether or not the user is already part of a call in another room.
var isParticipatingInOngoingCall = false
var shouldShowCallButton: Bool {
@@ -345,6 +345,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
state.roomTitle = roomInfo.displayName ?? roomProxy.id
state.roomAvatar = roomInfo.avatar
state.hasOngoingCall = roomInfo.hasRoomCall
state.activeRoomCallIntent = roomInfo.activeRoomCallIntent
state.hasSuccessor = roomInfo.successor != nil
let pinnedEventIDs = roomInfo.pinnedEventIDs
@@ -15,8 +15,8 @@ struct RoomCallControlsToolbar: ToolbarContent {
var body: some ToolbarContent {
if viewState.hasOngoingCall {
ToolbarItem(placement: .primaryAction) {
JoinCallButton {
onCallTap(false)
JoinCallButton(isVoiceCall: viewState.activeRoomCallIntent == .audio) {
onCallTap(viewState.activeRoomCallIntent == .audio)
}
.accessibilityIdentifier(A11yIdentifiers.roomScreen.joinCall)
.disabled(!viewState.canJoinCall)
@@ -61,16 +61,21 @@ struct RoomCallControlsToolbar_Previews: PreviewProvider {
ElementNavigationStack {
Color.clear.toolbar { RoomCallControlsToolbar(viewState: .mock(hasOngoingCall: false, canJoinCall: false)) { _ in } }
}
ElementNavigationStack {
Color.clear.toolbar { RoomCallControlsToolbar(viewState: .mock(hasOngoingCall: true, activeRoomCallIntent: .audio)) { _ in } }
}
}
.previewDisplayName("All states")
}
}
private extension RoomScreenViewState {
static func mock(hasOngoingCall: Bool, isDirectOneToOneRoom: Bool = false, canJoinCall: Bool = true) -> RoomScreenViewState {
static func mock(hasOngoingCall: Bool, isDirectOneToOneRoom: Bool = false, canJoinCall: Bool = true, activeRoomCallIntent: CallIntent? = nil) -> RoomScreenViewState {
RoomScreenViewState(roomAvatar: .room(id: "mock", name: "Mock Room", avatarURL: nil),
canJoinCall: canJoinCall,
hasOngoingCall: hasOngoingCall, isDirectOneToOneRoom: isDirectOneToOneRoom,
hasOngoingCall: hasOngoingCall,
activeRoomCallIntent: activeRoomCallIntent,
isDirectOneToOneRoom: isDirectOneToOneRoom,
hasSuccessor: false)
}
}