@@ -178,6 +178,8 @@ open class CallViewModel: ObservableObject {
178
178
/// The variable will be reset to `false` when `leaveCall` will be invoked.
179
179
private(set) var localCallSettingsChange = false
180
180
181
+ private var hasAcceptedCall = false
182
+
181
183
public var participants: [CallParticipant] {
182
184
let updateParticipants = call?.state.participants ?? []
183
185
return updateParticipants.filter {
@@ -444,6 +446,7 @@ open class CallViewModel: ObservableObject {
444
446
Task {
445
447
let call = streamVideo.call(callType: callType, callId: callId)
446
448
do {
449
+ hasAcceptedCall = true
447
450
try await call.accept()
448
451
enterCall(
449
452
call: call,
@@ -453,6 +456,7 @@ open class CallViewModel: ObservableObject {
453
456
customData: customData
454
457
)
455
458
} catch {
459
+ hasAcceptedCall = false
456
460
self.error = error
457
461
setCallingState(.idle)
458
462
self.call = nil
@@ -671,7 +675,9 @@ open class CallViewModel: ObservableObject {
671
675
)
672
676
save(call: call)
673
677
enteringCallTask = nil
678
+ hasAcceptedCall = false
674
679
} catch {
680
+ hasAcceptedCall = false
675
681
log.error("Error starting a call", error: error)
676
682
self.error = error
677
683
setCallingState(.idle)
@@ -792,7 +798,7 @@ open class CallViewModel: ObservableObject {
792
798
switch callingState {
793
799
case let .incoming(incomingCall)
794
800
where event.callCid == callCid(from: incomingCall.id, callType: incomingCall.type) && event.user?.id == streamVideo.user
795
- .id && enteringCallTask == nil :
801
+ .id && !hasAcceptedCall :
796
802
/// If the call that was accepted is the incoming call we are presenting, then we reject
797
803
/// and set the activeCall to the current one in order to reset the callingState to
798
804
/// inCall or idle.
0 commit comments