mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +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 }
|
set(value) { underlyingHasOngoingCall = value }
|
||||||
}
|
}
|
||||||
var underlyingHasOngoingCall: Bool!
|
var underlyingHasOngoingCall: Bool!
|
||||||
|
var activeRoomCallParticipants: [String] = []
|
||||||
var canonicalAlias: String?
|
var canonicalAlias: String?
|
||||||
var ownUserID: String {
|
var ownUserID: String {
|
||||||
get { return underlyingOwnUserID }
|
get { return underlyingOwnUserID }
|
||||||
|
|||||||
@@ -288,22 +288,31 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
|||||||
|
|
||||||
roomProxy
|
roomProxy
|
||||||
.actionsPublisher
|
.actionsPublisher
|
||||||
.map { action in
|
.map { action -> (Bool, [String]) in
|
||||||
switch action {
|
switch action {
|
||||||
case .roomInfoUpdate:
|
case .roomInfoUpdate:
|
||||||
return roomProxy.hasOngoingCall
|
return (roomProxy.hasOngoingCall, roomProxy.activeRoomCallParticipants)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.removeDuplicates()
|
.removeDuplicates { $0 == $1 }
|
||||||
.dropFirst(isCallOngoing ? 0 : 1)
|
.dropFirst(isCallOngoing ? 0 : 1)
|
||||||
.sink { [weak self] hasOngoingCall in
|
.sink { [weak self] hasOngoingCall, activeRoomCallParticipants in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
|
let participants: [String] = activeRoomCallParticipants
|
||||||
|
|
||||||
if !hasOngoingCall {
|
if !hasOngoingCall {
|
||||||
MXLog.info("Call has been cancelled")
|
MXLog.info("Call cancelled by remote")
|
||||||
|
|
||||||
cancellables.removeAll()
|
cancellables.removeAll()
|
||||||
endUnansweredCallTask?.cancel()
|
endUnansweredCallTask?.cancel()
|
||||||
callProvider.reportCall(with: incomingCallID.callKitID, endedAt: nil, reason: .remoteEnded)
|
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)
|
.store(in: &cancellables)
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
room.hasActiveRoomCall()
|
room.hasActiveRoomCall()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var activeRoomCallParticipants: [String] {
|
||||||
|
room.activeRoomCallParticipants()
|
||||||
|
}
|
||||||
|
|
||||||
var canonicalAlias: String? {
|
var canonicalAlias: String? {
|
||||||
room.canonicalAlias()
|
room.canonicalAlias()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ protocol RoomProxyProtocol {
|
|||||||
var pinnedEventIDs: Set<String> { get async }
|
var pinnedEventIDs: Set<String> { get async }
|
||||||
var membership: Membership { get }
|
var membership: Membership { get }
|
||||||
var inviter: RoomMemberProxyProtocol? { get async }
|
var inviter: RoomMemberProxyProtocol? { get async }
|
||||||
|
|
||||||
var hasOngoingCall: Bool { get }
|
var hasOngoingCall: Bool { get }
|
||||||
|
var activeRoomCallParticipants: [String] { get }
|
||||||
|
|
||||||
var canonicalAlias: String? { get }
|
var canonicalAlias: String? { get }
|
||||||
var ownUserID: String { get }
|
var ownUserID: String { get }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user