Hook up CallKit lock screen muting controls to the ElementCall widget

This commit is contained in:
Stefan Ceriu
2024-06-27 14:33:16 +03:00
committed by Stefan Ceriu
parent 2cce310540
commit d16ba9f3ef
6 changed files with 108 additions and 8 deletions
@@ -58,11 +58,35 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
return
}
// TODO: intercept EC mute state changes and pass them over to CallKit
// elementCallService.setCallMuted(roomID: roomProxy.id, muted: muted)
Task {
await self.widgetDriver.sendMessage(message)
}
}
elementCallService.actions
.receive(on: DispatchQueue.main)
.sink { [weak self] action in
guard let self else { return }
switch action {
case let .setCallMuted(muted, roomID):
guard roomID == roomProxy.id else {
MXLog.error("Received mute request for a different room: \(roomID) != \(roomProxy.id)")
return
}
Task {
await self.setMuted(muted)
}
default:
break
}
}
.store(in: &cancellables)
widgetDriver.messagePublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] receivedMessage in
@@ -115,6 +139,8 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
await elementCallService.setupCallSession(roomID: roomProxy.id, roomDisplayName: roomProxy.roomTitle)
// TODO: Pass over the current EC mute status to CallKit
let _ = await roomProxy.sendCallNotificationIfNeeeded()
}
}
@@ -137,6 +163,10 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
// MARK: - Private
private func setMuted(_ muted: Bool) async {
// Not supported on EC yet
}
private func hangUp() async {
let hangUpMessage = """
{"api":"fromWidget",