Skip to content

Commit 1273b37

Browse files
authored
[Fix]Update OutgoingCallScreen from the ringingCall (#798)
1 parent af3b074 commit 1273b37

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ _May 05, 2025_
1616
- Fix ringing flow issues. [#792](https://github.com/GetStream/stream-video-swift/pull/792)
1717
- Fix a few points that were negatively affecting Picture-in-Picture lifecycle. [#796](https://github.com/GetStream/stream-video-swift/pull/796)
1818

19+
### 🔄 Changed
20+
- Update OutgoingCallView to get updates from ringing call [#798](https://github.com/GetStream/stream-video-swift/pull/798)
21+
1922
# [1.21.1](https://github.com/GetStream/stream-video-swift/releases/tag/1.21.1)
2023
_April 25, 2025_
2124

Sources/StreamVideoSwiftUI/CallView/CallControls/Stateful/CallControlsView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ public struct CallControlsView: View {
1212
@Injected(\.colors) var colors
1313

1414
@ObservedObject var viewModel: CallViewModel
15+
@State var ownCapabilities: [OwnCapability]
1516

1617
/// Initializes the call controls view with a view model.
1718
/// - Parameter viewModel: The view model for the call controls.
1819
public init(viewModel: CallViewModel) {
1920
self.viewModel = viewModel
21+
ownCapabilities = viewModel.call?.state.ownCapabilities ?? []
2022
}
2123

2224
public var body: some View {
2325
HStack {
24-
if call?.state.ownCapabilities.contains(.sendVideo) == true {
26+
if ownCapabilities.contains(.sendVideo) == true {
2527
VideoIconView(viewModel: viewModel)
2628
}
27-
if call?.state.ownCapabilities.contains(.sendAudio) == true {
29+
if ownCapabilities.contains(.sendAudio) == true {
2830
MicrophoneIconView(viewModel: viewModel)
2931
}
3032

@@ -37,6 +39,8 @@ public struct CallControlsView: View {
3739
.padding(.horizontal, 16)
3840
.padding(.vertical)
3941
.frame(maxWidth: .infinity)
42+
.onReceive(viewModel.call?.state.$ownCapabilities.receive(on: DispatchQueue.main)) { ownCapabilities = $0 }
43+
.onReceive(streamVideo.state.ringingCall?.state.$ownCapabilities.receive(on: DispatchQueue.main)) { ownCapabilities = $0 }
4044
}
4145

4246
private var call: Call? {

Sources/StreamVideoSwiftUI/CallingViews/CallConnectingView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct CallConnectingView<CallControls: View, CallTopView: View, Factory:
1414
@Injected(\.utils) var utils
1515

1616
var viewFactory: Factory
17-
public var outgoingCallMembers: [Member]
17+
@State public var outgoingCallMembers: [Member]
1818
public var title: String
1919
public var callControls: CallControls
2020
public var callTopView: CallTopView
@@ -75,5 +75,8 @@ public struct CallConnectingView<CallControls: View, CallTopView: View, Factory:
7575
.background(
7676
OutgoingCallBackground(outgoingCallMembers: outgoingCallMembers)
7777
)
78+
.onReceive(streamVideo.state.ringingCall?.state.$members.receive(on: DispatchQueue.main)) { members in
79+
outgoingCallMembers = members.filter { $0.id != streamVideo.user.id }
80+
}
7881
}
7982
}

StreamVideoSwiftUITests/CallView/CallControls/Stateful/CallControlsView_Tests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ final class CallControlsView_Tests: StreamVideoUITestCase, @unchecked Sendable {
2323
func test_callControlsView_activeCall_snapshot() throws {
2424
let call = streamVideoUI?.streamVideo.call(callType: .default, callId: .unique)
2525
call?.state.ownCapabilities = [.sendAudio, .sendVideo]
26+
streamVideoUI?.streamVideo.state.ringingCall = call
2627
let viewModel = CallViewModel()
2728
viewModel.setActiveCall(call)
2829

@@ -39,6 +40,7 @@ final class CallControlsView_Tests: StreamVideoUITestCase, @unchecked Sendable {
3940
call.state.ownCapabilities = [.sendAudio, .sendVideo]
4041
streamVideoUI?.streamVideo.state.ringingCall = call
4142
let viewModel = CallViewModel()
43+
viewModel.setActiveCall(call)
4244
viewModel.callingState = .outgoing
4345

4446
let view = CallControlsView(viewModel: viewModel)

StreamVideoSwiftUITests/CallingViews/CallConnectingView_Tests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ final class CallConnectingView_Tests: StreamVideoUITestCase, @unchecked Sendable
2525
call.state.ownCapabilities.append(.sendAudio)
2626
call.state.ownCapabilities.append(.sendVideo)
2727
streamVideoUI?.streamVideo.state.ringingCall = call
28+
viewModel.setActiveCall(call)
2829
viewModel.callingState = .outgoing
2930

3031
let view = CallConnectingView(

StreamVideoSwiftUITests/CallingViews/OutgoingCallView_Tests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ final class OutgoingCallView_Tests: StreamVideoUITestCase, @unchecked Sendable {
2929
.init(user: viewModel.streamVideo.user),
3030
.init(userId: "test-user")
3131
]
32-
viewModel.callingState = .outgoing
3332
viewModel.streamVideo.state.ringingCall = call
33+
viewModel.setActiveCall(call)
34+
viewModel.callingState = .outgoing
3435

3536
let view = factory.makeOutgoingCallView(viewModel: viewModel)
3637

0 commit comments

Comments
 (0)