Skip to content

Commit 65a3759

Browse files
Fix handling of session join/leave events for existing users (#769)
1 parent fd91c69 commit 65a3759

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/StreamVideo/CallState.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,16 @@ public class CallState: ObservableObject {
209209
case let .typeCallSessionEndedEvent(event):
210210
update(from: event.call)
211211
case let .typeCallSessionParticipantJoinedEvent(event):
212-
if session?.participants.contains(event.participant) == false {
212+
if let index = session?.participants.firstIndex(where: {
213+
$0.userSessionId == event.participant.userSessionId
214+
}), index < (session?.participants.count ?? 0) {
215+
session?.participants[index] = event.participant
216+
} else {
213217
session?.participants.append(event.participant)
214218
}
215219
case let .typeCallSessionParticipantLeftEvent(event):
216220
session?.participants.removeAll(where: { participant in
217-
participant == event.participant
221+
participant.userSessionId == event.participant.userSessionId
218222
})
219223
case let .typeCallSessionStartedEvent(event):
220224
update(from: event.call)

0 commit comments

Comments
 (0)