@@ -178,6 +178,8 @@ open class CallViewModel: ObservableObject {
178178 /// The variable will be reset to `false` when `leaveCall` will be invoked.
179179 private( set) var localCallSettingsChange = false
180180
181+ private var hasAcceptedCall = false
182+
181183 public var participants : [ CallParticipant ] {
182184 let updateParticipants = call? . state. participants ?? [ ]
183185 return updateParticipants. filter {
@@ -444,6 +446,7 @@ open class CallViewModel: ObservableObject {
444446 Task {
445447 let call = streamVideo. call ( callType: callType, callId: callId)
446448 do {
449+ hasAcceptedCall = true
447450 try await call. accept ( )
448451 enterCall (
449452 call: call,
@@ -453,6 +456,7 @@ open class CallViewModel: ObservableObject {
453456 customData: customData
454457 )
455458 } catch {
459+ hasAcceptedCall = false
456460 self . error = error
457461 setCallingState ( . idle)
458462 self . call = nil
@@ -671,7 +675,9 @@ open class CallViewModel: ObservableObject {
671675 )
672676 save ( call: call)
673677 enteringCallTask = nil
678+ hasAcceptedCall = false
674679 } catch {
680+ hasAcceptedCall = false
675681 log. error ( " Error starting a call " , error: error)
676682 self . error = error
677683 setCallingState ( . idle)
@@ -792,7 +798,7 @@ open class CallViewModel: ObservableObject {
792798 switch callingState {
793799 case let . incoming( incomingCall)
794800 where event. callCid == callCid ( from: incomingCall. id, callType: incomingCall. type) && event. user? . id == streamVideo. user
795- . id && enteringCallTask == nil :
801+ . id && !hasAcceptedCall :
796802 /// If the call that was accepted is the incoming call we are presenting, then we reject
797803 /// and set the activeCall to the current one in order to reset the callingState to
798804 /// inCall or idle.
0 commit comments