mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Fix #3133 - Cancel ElementCall rining once answered elsewhere
- expose `activeRoomCallParticipants` and use them to detect if the user has joined the call from a different device
This commit is contained in:
committed by
Stefan Ceriu
parent
9b9f45ea0c
commit
0b984cc3eb
@@ -8359,6 +8359,7 @@ class RoomProxyMock: RoomProxyProtocol {
|
||||
set(value) { underlyingHasOngoingCall = value }
|
||||
}
|
||||
var underlyingHasOngoingCall: Bool!
|
||||
var activeRoomCallParticipants: [String] = []
|
||||
var canonicalAlias: String?
|
||||
var ownUserID: String {
|
||||
get { return underlyingOwnUserID }
|
||||
|
||||
@@ -288,22 +288,31 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
||||
|
||||
roomProxy
|
||||
.actionsPublisher
|
||||
.map { action in
|
||||
.map { action -> (Bool, [String]) in
|
||||
switch action {
|
||||
case .roomInfoUpdate:
|
||||
return roomProxy.hasOngoingCall
|
||||
return (roomProxy.hasOngoingCall, roomProxy.activeRoomCallParticipants)
|
||||
}
|
||||
}
|
||||
.removeDuplicates()
|
||||
.removeDuplicates { $0 == $1 }
|
||||
.dropFirst(isCallOngoing ? 0 : 1)
|
||||
.sink { [weak self] hasOngoingCall in
|
||||
.sink { [weak self] hasOngoingCall, activeRoomCallParticipants in
|
||||
guard let self else { return }
|
||||
|
||||
let participants: [String] = activeRoomCallParticipants
|
||||
|
||||
if !hasOngoingCall {
|
||||
MXLog.info("Call has been cancelled")
|
||||
MXLog.info("Call cancelled by remote")
|
||||
|
||||
cancellables.removeAll()
|
||||
endUnansweredCallTask?.cancel()
|
||||
callProvider.reportCall(with: incomingCallID.callKitID, endedAt: nil, reason: .remoteEnded)
|
||||
} else if participants.contains(roomProxy.ownUserID) {
|
||||
MXLog.info("Call anwered elsewhere")
|
||||
|
||||
cancellables.removeAll()
|
||||
endUnansweredCallTask?.cancel()
|
||||
callProvider.reportCall(with: incomingCallID.callKitID, endedAt: nil, reason: .answeredElsewhere)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -123,6 +123,10 @@ class RoomProxy: RoomProxyProtocol {
|
||||
room.hasActiveRoomCall()
|
||||
}
|
||||
|
||||
var activeRoomCallParticipants: [String] {
|
||||
room.activeRoomCallParticipants()
|
||||
}
|
||||
|
||||
var canonicalAlias: String? {
|
||||
room.canonicalAlias()
|
||||
}
|
||||
|
||||
@@ -41,7 +41,10 @@ protocol RoomProxyProtocol {
|
||||
var pinnedEventIDs: Set<String> { get async }
|
||||
var membership: Membership { get }
|
||||
var inviter: RoomMemberProxyProtocol? { get async }
|
||||
|
||||
var hasOngoingCall: Bool { get }
|
||||
var activeRoomCallParticipants: [String] { get }
|
||||
|
||||
var canonicalAlias: String? { get }
|
||||
var ownUserID: String { get }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user