Skip to content

Commit 03e5a68

Browse files
committed
[Fix]Handle participantEvents only for the active call
1 parent 8b45e26 commit 03e5a68

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

Sources/StreamVideoSwiftUI/CallViewModel.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,15 +822,20 @@ open class CallViewModel: ObservableObject {
822822
self?.leaveCall()
823823
}
824824
case let .userBlocked(callEventInfo):
825-
if callEventInfo.user?.id == streamVideo.user.id {
825+
if
826+
callEventInfo.user?.id == streamVideo.user.id,
827+
callEventInfo.callCid == call?.cId
828+
{
826829
leaveCall()
827830
}
828831
case .userUnblocked:
829832
break
830833
case .sessionStarted:
831834
break
832835
}
833-
} else if let participantEvent = callEventsHandler.checkForParticipantEvents(from: event) {
836+
} else if
837+
let participantEvent = callEventsHandler.checkForParticipantEvents(from: event),
838+
participantEvent.callCid == call?.cId {
834839
guard participants.count < 25 else {
835840
log.debug("Skipping participant events for big calls")
836841
return

Sources/StreamVideoSwiftUI/Models/CallEventsHandler.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ public class CallEventsHandler {
8383
case let .typeCallSessionParticipantJoinedEvent(event):
8484
return ParticipantEvent(
8585
id: event.participant.user.id,
86+
callCid: event.callCid,
8687
action: .join,
8788
user: event.participant.user.name ?? event.participant.user.id,
8889
imageURL: URL(string: event.participant.user.image ?? "")
8990
)
9091
case let .typeCallSessionParticipantLeftEvent(event):
9192
return ParticipantEvent(
9293
id: event.participant.user.id,
94+
callCid: event.callCid,
9395
action: .leave,
9496
user: event.participant.user.name ?? event.participant.user.id,
9597
imageURL: URL(string: event.participant.user.image ?? "")

Sources/StreamVideoSwiftUI/Models/CallModels.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import SwiftUI
88
/// Represents a participant event during a call.
99
public struct ParticipantEvent: Sendable {
1010
public let id: String
11+
public let callCid: String
1112
public let action: ParticipantAction
1213
public let user: String
1314
public let imageURL: URL?

StreamVideoSwiftUITests/Utils/ParticipantEventResetAdapter/ParticipantEventResetAdapter_Tests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class ParticipantEventResetAdapter_Tests: XCTestCase, @unchecked Sendable
3131
_ = subject
3232
viewModel.participantEvent = .init(
3333
id: .unique,
34+
callCid: .unique,
3435
action: .join,
3536
user: .unique,
3637
imageURL: nil
@@ -47,6 +48,7 @@ final class ParticipantEventResetAdapter_Tests: XCTestCase, @unchecked Sendable
4748
group.addTask { @MainActor in
4849
self.viewModel.participantEvent = .init(
4950
id: .unique,
51+
callCid: .unique,
5052
action: .join,
5153
user: .unique,
5254
imageURL: nil
@@ -57,6 +59,7 @@ final class ParticipantEventResetAdapter_Tests: XCTestCase, @unchecked Sendable
5759

5860
self.viewModel.participantEvent = .init(
5961
id: .unique,
62+
callCid: .unique,
6063
action: .join,
6164
user: .unique,
6265
imageURL: nil

0 commit comments

Comments
 (0)