Skip to content

Commit

Permalink
[Alignment]Allow member lookup from call when members in request are …
Browse files Browse the repository at this point in the history
…empty (#660)
  • Loading branch information
ipavlidakis authored Feb 7, 2025
1 parent 5f0b694 commit 39b2518
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 22 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

# Upcoming

### 🔄 Changed
### 🐞 Fixed
- When a call is being created from another device than the one starting the call, if you don't provide any members, the SDK will get the information from the backend [#660](https://github.com/GetStream/stream-video-swift/pull/660)
- The `OutgoingCallView` provided by the default `ViewFactory` implementation won't show the current user in the ringing member bubbles [#660](https://github.com/GetStream/stream-video-swift/pull/660)


# [1.16.0](https://github.com/GetStream/stream-video-swift/releases/tag/1.16.0)
_January 31, 2025_
Expand Down
16 changes: 8 additions & 8 deletions Sources/StreamVideo/Call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
video: Bool? = nil,
transcription: TranscriptionSettingsRequest? = nil
) async throws -> CallResponse {
var membersRequest = [MemberRequest]()
memberIds?.forEach {
membersRequest.append(.init(userId: $0))
}
members?.forEach {
membersRequest.append($0)
let membersFromMemberIds = memberIds?
.map { MemberRequest(userId: $0) } ?? []

var aggregatedMembers: [MemberRequest]? = (members ?? []) + membersFromMemberIds
if aggregatedMembers?.isEmpty == true {
aggregatedMembers = nil
}

var settingsOverride: CallSettingsRequest?
var limits: LimitsSettingsRequest?
if maxDuration != nil || maxParticipants != nil {
Expand All @@ -277,7 +277,7 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
let request = GetOrCreateCallRequest(
data: CallRequest(
custom: custom,
members: membersRequest,
members: aggregatedMembers,
settingsOverride: settingsOverride,
startsAt: startsAt,
team: team,
Expand Down
6 changes: 4 additions & 2 deletions Sources/StreamVideoSwiftUI/CallViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,14 @@ open class CallViewModel: ObservableObject {
) {
outgoingCallMembers = members
callingState = ring ? .outgoing : .joining
let membersRequest = members.map(\.toMemberRequest)
let membersRequest: [MemberRequest]? = members.isEmpty
? nil
: members.map(\.toMemberRequest)
if !ring {
enterCall(
callType: callType,
callId: callId,
members: membersRequest,
members: membersRequest ?? [],
ring: ring,
maxDuration: maxDuration,
maxParticipants: maxParticipants,
Expand Down
13 changes: 11 additions & 2 deletions Sources/StreamVideoSwiftUI/ViewFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,18 @@ extension ViewFactory {
}

public func makeOutgoingCallView(viewModel: CallViewModel) -> some View {
OutgoingCallView(
var membersToShow = viewModel.outgoingCallMembers.isEmpty
? (viewModel.streamVideo.state.ringingCall?.state.members ?? viewModel.outgoingCallMembers)
: viewModel.outgoingCallMembers

// Remove the current user from the ringing members
membersToShow = membersToShow.filter {
viewModel.streamVideo.user.id != $0.user.id
}

return OutgoingCallView(
viewFactory: self,
outgoingCallMembers: viewModel.outgoingCallMembers,
outgoingCallMembers: membersToShow,
callTopView: makeCallTopView(viewModel: viewModel),
callControls: makeCallControlsView(viewModel: viewModel)
)
Expand Down
17 changes: 12 additions & 5 deletions StreamVideoSwiftUITests/CallingViews/OutgoingCallView_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ final class OutgoingCallView_Tests: StreamVideoUITestCase {

func test_outgoingCallView_snapshot() throws {
let viewModel = CallViewModel()
let view = OutgoingCallView(
outgoingCallMembers: viewModel.outgoingCallMembers,
callTopView: factory.makeCallTopView(viewModel: viewModel),
callControls: factory.makeCallControlsView(viewModel: viewModel)
)
let call = try XCTUnwrap(streamVideoUI?.streamVideo.call(callType: .default, callId: .unique))
call.state.ownCapabilities.append(.sendAudio)
call.state.ownCapabilities.append(.sendVideo)
call.state.members = [
.init(user: viewModel.streamVideo.user),
.init(userId: "test-user")
]
viewModel.callingState = .outgoing
viewModel.streamVideo.state.ringingCall = call

let view = factory.makeOutgoingCallView(viewModel: viewModel)

AssertSnapshot(view, variants: snapshotVariants)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions SwiftUIDemoAppUITests/Tests/RingProcessTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class RingProcessTests: StreamTestCase {
}
THEN("all required elements are on the screen") {
userRobot
.assertConnectingView(with: participants + user)
.assertConnectingView(with: participants)
.assertCallControls()
}
}
Expand All @@ -38,7 +38,7 @@ final class RingProcessTests: StreamTestCase {
}
THEN("all required elements are on the screen") {
userRobot
.assertConnectingView(with: participants + user)
.assertConnectingView(with: participants)
.assertCallControls()
}
}
Expand All @@ -57,7 +57,7 @@ final class RingProcessTests: StreamTestCase {
}
THEN("all required elements are on the screen") {
userRobot
.assertConnectingView(with: participants + user)
.assertConnectingView(with: participants)
.assertCallControls()
}
}
Expand All @@ -76,7 +76,7 @@ final class RingProcessTests: StreamTestCase {
}
THEN("all required elements are on the screen") {
userRobot
.assertConnectingView(with: participants + user)
.assertConnectingView(with: participants)
.assertCallControls()
}
}
Expand Down

0 comments on commit 39b2518

Please sign in to comment.