diff --git a/Linphone/TelecomManager/ProviderDelegate.swift b/Linphone/TelecomManager/ProviderDelegate.swift index 56448304a..8eb6a3617 100644 --- a/Linphone/TelecomManager/ProviderDelegate.swift +++ b/Linphone/TelecomManager/ProviderDelegate.swift @@ -222,13 +222,18 @@ extension ProviderDelegate: CXProviderDelegate { let call = core.getCallByCallid(callId: callId) + let callLogIsNil = call?.callLog != nil + + let videoEnabledTmp = call?.params?.videoEnabled + let wasConferenceTmp = call?.callLog?.wasConference() + DispatchQueue.main.async { if UIApplication.shared.applicationState != .active { TelecomManager.shared.backgroundContextCall = call - if call?.callLog != nil { - TelecomManager.shared.backgroundContextCameraIsEnabled = call?.params?.videoEnabled == true || call?.callLog?.wasConference() == true + if callLogIsNil { + TelecomManager.shared.backgroundContextCameraIsEnabled = videoEnabledTmp == true || wasConferenceTmp == true } else { - TelecomManager.shared.backgroundContextCameraIsEnabled = call?.params?.videoEnabled == true + TelecomManager.shared.backgroundContextCameraIsEnabled = videoEnabledTmp == true } if #available(iOS 16.0, *) { diff --git a/Linphone/TelecomManager/TelecomManager.swift b/Linphone/TelecomManager/TelecomManager.swift index ce2af3f1f..3f7b3f85c 100644 --- a/Linphone/TelecomManager/TelecomManager.swift +++ b/Linphone/TelecomManager/TelecomManager.swift @@ -319,6 +319,15 @@ class TelecomManager: ObservableObject { DispatchQueue.main.async { self.callStarted = true self.isNotVerifiedCounter = 0 + if self.callDisplayed { + self.callDisplayed = core.calls.count <= 1 + } + } + + if core.calls.count > 1 { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + self.callDisplayed = true + } } } catch { Log.error("accept call failed \(error)") diff --git a/Linphone/UI/Call/CallView.swift b/Linphone/UI/Call/CallView.swift index 051f0f8e6..5e0fe18c7 100644 --- a/Linphone/UI/Call/CallView.swift +++ b/Linphone/UI/Call/CallView.swift @@ -1915,7 +1915,7 @@ struct CallView: View { if callViewModel.isOneOneCall { VStack { Button { - if callViewModel.calls.count < 2 { + if callViewModel.callsCounter < 2 { withAnimation { callViewModel.isTransferInsteadCall = true MagicSearchSingleton.shared.searchForSuggestions() @@ -1938,7 +1938,7 @@ struct CallView: View { .background(Color.gray500) .cornerRadius(40) - Text(callViewModel.calls.count < 2 ? "Transfer" : "Attended transfer") + Text(callViewModel.callsCounter < 2 ? "Transfer" : "Attended transfer") .foregroundStyle(.white) .default_text_style(styleSize: 15) } @@ -2039,13 +2039,13 @@ struct CallView: View { .background(Color.gray500) .cornerRadius(40) - if callViewModel.calls.count > 1 { + if callViewModel.callsCounter > 1 { VStack { HStack { Spacer() VStack { - Text("\(callViewModel.calls.count)") + Text("\(callViewModel.callsCounter)") .foregroundStyle(.white) .default_text_style(styleSize: 15) } @@ -2261,7 +2261,7 @@ struct CallView: View { .background(Color.gray500) .cornerRadius(40) - Text(callViewModel.calls.count < 2 ? "Transfer" : "Attended transfer") + Text(callViewModel.callsCounter < 2 ? "Transfer" : "Attended transfer") .foregroundStyle(.white) .default_text_style(styleSize: 15) } @@ -2365,13 +2365,13 @@ struct CallView: View { .background(Color.gray500) .cornerRadius(40) - if callViewModel.calls.count > 1 { + if callViewModel.callsCounter > 1 { VStack { HStack { Spacer() VStack { - Text("\(callViewModel.calls.count)") + Text("\(callViewModel.callsCounter)") .foregroundStyle(.white) .default_text_style(styleSize: 15) } diff --git a/Linphone/UI/Call/Fragments/CallsListFragment.swift b/Linphone/UI/Call/Fragments/CallsListFragment.swift index 171f11696..ae6bf53b5 100644 --- a/Linphone/UI/Call/Fragments/CallsListFragment.swift +++ b/Linphone/UI/Call/Fragments/CallsListFragment.swift @@ -327,7 +327,7 @@ struct CallsListFragment: View { .listStyle(.plain) .overlay( VStack { - if callViewModel.calls.isEmpty { + if callViewModel.callsCounter == 0 { Spacer() Image("illus-belledonne") .resizable() diff --git a/Linphone/UI/Call/ViewModel/CallViewModel.swift b/Linphone/UI/Call/ViewModel/CallViewModel.swift index bf19b6f48..03602c008 100644 --- a/Linphone/UI/Call/ViewModel/CallViewModel.swift +++ b/Linphone/UI/Call/ViewModel/CallViewModel.swift @@ -65,6 +65,7 @@ class CallViewModel: ObservableObject { private var mConferenceSuscriptions = Set() @Published var calls: [Call] = [] + @Published var callsCounter: Int = 0 @Published var callsContactAvatarModel: [ContactAvatarModel?] = [] let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() @@ -106,10 +107,11 @@ class CallViewModel: ObservableObject { coreContext.doOnCoreQueue { core in if core.currentCall != nil && core.currentCall!.remoteAddress != nil { self.currentCall = core.currentCall - self.callSuscriptions.removeAll() self.mConferenceSuscriptions.removeAll() + let callsCounterTmp = core.calls.count + var videoDisplayedTmp = false do { let params = try core.createCallParams(call: self.currentCall) @@ -221,6 +223,8 @@ class CallViewModel: ObservableObject { self.getCallsList() + self.callsCounter = callsCounterTmp + if self.currentCall?.conference?.state == .Created { self.getConference() } else { diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index 0c47599f1..d6d1efbb3 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -73,7 +73,7 @@ struct ContentView: View { GeometryReader { geometry in VStack(spacing: 0) { - if telecomManager.callInProgress && !fullscreenVideo && ((!telecomManager.callDisplayed && callViewModel.calls.count == 1) || callViewModel.calls.count > 1) { + if telecomManager.callInProgress && !fullscreenVideo && ((!telecomManager.callDisplayed && callViewModel.callsCounter == 1) || callViewModel.callsCounter > 1) { HStack { Image("phone") .renderingMode(.template) @@ -82,8 +82,8 @@ struct ContentView: View { .frame(width: 26, height: 26) .padding(.leading, 10) - if callViewModel.calls.count > 1 { - Text("\(callViewModel.calls.count) appels") + if callViewModel.callsCounter > 1 { + Text("\(callViewModel.callsCounter) appels") .default_text_style_white(styleSize: 16) } else { Text("\(callViewModel.displayName)") @@ -92,7 +92,7 @@ struct ContentView: View { Spacer() - if callViewModel.calls.count == 1 { + if callViewModel.callsCounter == 1 { Text("\(callViewModel.isPaused || telecomManager.isPausedByRemote ? "En pause" : "Actif")") .default_text_style_white(styleSize: 16) .padding(.trailing, 10) @@ -1024,7 +1024,7 @@ struct ContentView: View { .onAppear { UIApplication.shared.isIdleTimerDisabled = true callViewModel.resetCallView() - if callViewModel.calls.count >= 1 { + if callViewModel.callsCounter >= 1 { DispatchQueue.main.asyncAfter(deadline: .now() + 1) { callViewModel.resetCallView() }