Skip to content

Commit b2537e7

Browse files
authored
[Fix]Ringing flow issues (#792)
1 parent 503a0b4 commit b2537e7

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44

55
# Upcoming
66

7-
### 🔄 Changed
7+
### 🐞 Fixed
8+
- Fix ringing flow issues. [#792](https://github.com/GetStream/stream-video-swift/pull/792)
89

910
# [1.21.1](https://github.com/GetStream/stream-video-swift/releases/tag/1.21.1)
1011
_April 25, 2025_

Sources/StreamVideoSwiftUI/CallViewModel.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,9 @@ open class CallViewModel: ObservableObject {
764764
// TODO: implement holding a call.
765765
if callingState == .idle && isAppActive {
766766
setCallingState(.incoming(incomingCall))
767+
/// We start the ringing timer, so we can cancel when the timeout
768+
/// is over.
769+
startTimer(timeout: incomingCall.timeout)
767770
}
768771
}
769772
case .accepted:
@@ -836,15 +839,16 @@ open class CallViewModel: ObservableObject {
836839

837840
switch callingState {
838841
case let .incoming(incomingCall) where event.callCid == callCid(from: incomingCall.id, callType: incomingCall.type):
839-
/// If the call that was rejected is the incoming call we are presenting, then we reject
840-
/// and set the activeCall to the current one in order to reset the callingState to
841-
/// inCall or idle.
842-
Task {
843-
_ = try? await streamVideo
844-
.call(callType: incomingCall.type, callId: incomingCall.id)
845-
.reject()
846-
setActiveCall(call)
842+
let isCurrentUserRejection = event.user?.id == streamVideo.user.id
843+
let isCallCreatorRejection = event.user?.id == incomingCall.caller.id
844+
845+
guard
846+
(isCurrentUserRejection || isCallCreatorRejection)
847+
else {
848+
return
847849
}
850+
851+
setActiveCall(call)
848852
case .outgoing where call?.cId == event.callCid:
849853
guard let outgoingCall = call else {
850854
return

0 commit comments

Comments
 (0)