Fix setHeldOtherCalls when current call is paused, remove setHeldOtherCallsWithCore function

This commit is contained in:
Benoit Martins 2024-01-25 14:52:04 +01:00
parent 5ab64968e3
commit ffb60daaea
3 changed files with 21 additions and 19 deletions

View file

@ -97,7 +97,7 @@ class TelecomManager: ObservableObject {
if TelecomManager.callKitEnabled(core: core) {// && !nextCallIsTransfer != true {
let uuid = UUID()
let name = addr?.asStringUriOnly() ?? "unknow" // FastAddressBook.displayName(for: addr) ?? "unknow"
let name = addr?.asStringUriOnly() ?? "Unknown"
let handle = CXHandle(type: .generic, value: addr?.asStringUriOnly() ?? "")
let startCallAction = CXStartCallAction(call: uuid, handle: handle)
let transaction = CXTransaction(action: startCallAction)
@ -113,20 +113,12 @@ class TelecomManager: ObservableObject {
}
}
func setHeldOtherCallsWithCore(exceptCallid: String) {
CoreContext.shared.doOnCoreQueue { core in
for call in core.calls {
if (call.callLog?.callId != exceptCallid && call.state != .Paused && call.state != .Pausing && call.state != .PausedByRemote) {
self.setHeld(call: call, hold: true)
}
}
}
}
func setHeldOtherCalls(core: Core, exceptCallid: String) {
for call in core.calls {
if (call.callLog?.callId != exceptCallid && call.state != .Paused && call.state != .Pausing && call.state != .PausedByRemote) {
setHeld(call: call, hold: true)
} else if call.callLog?.callId == exceptCallid && (call.state == .Paused || call.state == .Pausing || call.state == .PausedByRemote) {
setHeld(call: call, hold: true)
}
}
}
@ -544,8 +536,6 @@ class TelecomManager: ObservableObject {
.OutgoingRinging,
.OutgoingEarlyMedia:
print("OutgoingInitOutgoingInit \(core.maxCalls)")
if TelecomManager.callKitEnabled(core: core) {
let uuid = providerDelegate.uuids[""]
if uuid != nil {

View file

@ -121,8 +121,14 @@ struct CallsListFragment: View {
isShowCallsListBottomSheet = false
} else {
TelecomManager.shared.setHeldOtherCallsWithCore(exceptCallid: "")
TelecomManager.shared.setHeld(call: callViewModel.selectedCall!, hold: callViewModel.selectedCall!.state == .StreamsRunning)
CoreContext.shared.doOnCoreQueue { core in
if callViewModel.currentCall!.state == .StreamsRunning {
TelecomManager.shared.setHeldOtherCalls(core: core, exceptCallid: "")
} else {
TelecomManager.shared.setHeldOtherCalls(core: core, exceptCallid: callViewModel.currentCall?.callLog?.callId ?? "")
}
}
TelecomManager.shared.setHeld(call: callViewModel.selectedCall!, hold: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
callViewModel.resetCallView()
@ -327,8 +333,14 @@ struct CallsListFragment: View {
}
}
} else {
TelecomManager.shared.setHeldOtherCallsWithCore(exceptCallid: "")
TelecomManager.shared.setHeld(call: callViewModel.calls[index], hold: callViewModel.calls[index].state == .StreamsRunning)
CoreContext.shared.doOnCoreQueue { core in
if callViewModel.currentCall!.state == .StreamsRunning {
TelecomManager.shared.setHeldOtherCalls(core: core, exceptCallid: "")
} else {
TelecomManager.shared.setHeldOtherCalls(core: core, exceptCallid: callViewModel.currentCall?.callLog?.callId ?? "")
}
}
TelecomManager.shared.setHeld(call: callViewModel.calls[index], hold: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
callViewModel.resetCallView()

View file

@ -42,8 +42,8 @@ class CallViewModel: ObservableObject {
@Published var upperCaseAuthTokenToListen = ""
@Published var isMediaEncrypted: Bool = false
@Published var isZrtpPq: Bool = false
@Published var isRemoteDeviceTrusted: Bool = false
@Published var selectedCall: Call? = nil
@Published var isRemoteDeviceTrusted: Bool = false
@Published var selectedCall: Call? = nil
var calls: [Call] = []