diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt index bb8212bb73..6380b6d4cd 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt @@ -763,13 +763,24 @@ public class CallState( } is ParticipantLeftEvent -> { - removeParticipant(event.participant.session_id) + val sessionId = event.participant.session_id + removeParticipant(sessionId) // clean up - stop screen-sharing session if it was still running val current = _screenSharingSession.value - if (current?.participant?.sessionId == event.participant.session_id) { + if (current?.participant?.sessionId == sessionId) { _screenSharingSession.value = null } + if (_localPins.value.containsKey(sessionId)) { + // Remove any pins for the participant + unpin(sessionId) + } + + if (_serverPins.value.containsKey(sessionId)) { + scope.launch { + call.unpinForEveryone(sessionId, event.participant.user_id) + } + } } is SubscriberOfferEvent -> {