ios: remove no longer needed code

Ever since we switched to handling track events instead of mute actions this has
been dead code. It was also added in the wrong place, since it's responsibility
of the JS code to solve the ping-pong problem.
This commit is contained in:
Saúl Ibarra Corretgé 2019-04-16 17:47:48 +02:00 committed by Saúl Ibarra Corretgé
parent c1f8a35156
commit 603d161788
2 changed files with 2 additions and 28 deletions

View File

@ -21,7 +21,6 @@ import Foundation
internal final class JMCallKitEmitter: NSObject, CXProviderDelegate { internal final class JMCallKitEmitter: NSObject, CXProviderDelegate {
private var listeners = Set<JMCallKitEventListenerWrapper>() private var listeners = Set<JMCallKitEventListenerWrapper>()
private var pendingMuteActions = Set<UUID>()
internal override init() {} internal override init() {}
@ -57,17 +56,10 @@ internal final class JMCallKitEmitter: NSObject, CXProviderDelegate {
} }
} }
// MARK: - Add mute action
func addMuteAction(_ actionUUID: UUID) {
pendingMuteActions.insert(actionUUID)
}
// MARK: - CXProviderDelegate // MARK: - CXProviderDelegate
func providerDidReset(_ provider: CXProvider) { func providerDidReset(_ provider: CXProvider) {
listeners.forEach { $0.listener?.providerDidReset?() } listeners.forEach { $0.listener?.providerDidReset?() }
pendingMuteActions.removeAll()
} }
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) { func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
@ -87,17 +79,8 @@ internal final class JMCallKitEmitter: NSObject, CXProviderDelegate {
} }
func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) { func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
let uuid = pendingMuteActions.remove(action.uuid) listeners.forEach {
$0.listener?.performSetMutedCall?(UUID: action.callUUID, isMuted: action.isMuted)
// XXX avoid mute actions ping-pong: if the mute action was caused by
// the JS side (we requested a transaction) don't call the delegate
// method. If it was called by the provder itself (when the user presses
// the mute button in the CallKit view) then call the delegate method.
if (uuid == nil) {
listeners.forEach {
$0.listener?.performSetMutedCall?(UUID: action.callUUID,
isMuted: action.isMuted)
}
} }
action.fulfill() action.fulfill()

View File

@ -156,14 +156,6 @@ import Foundation
completion: @escaping (Error?) -> Swift.Void) { completion: @escaping (Error?) -> Swift.Void) {
guard enabled else { return } guard enabled else { return }
// XXX keep track of muted actions to avoid "ping-pong"ing. See
// JMCallKitEmitter for details on the CXSetMutedCallAction handling.
for action in transaction.actions {
if (action as? CXSetMutedCallAction) != nil {
emitter.addMuteAction(action.uuid)
}
}
callController.request(transaction, completion: completion) callController.request(transaction, completion: completion)
} }
@ -191,4 +183,3 @@ import Foundation
return update return update
} }
} }