From c12c55413833120706fcd653c1b719c0c2eb8fef Mon Sep 17 00:00:00 2001 From: Jaya Allamsetty Date: Thu, 15 Apr 2021 16:12:31 -0400 Subject: [PATCH] fix(video-layout): Unpin SS when the screensharing participant leaves. --- react/features/video-layout/subscriber.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/react/features/video-layout/subscriber.js b/react/features/video-layout/subscriber.js index bf8584f70..abda9072e 100644 --- a/react/features/video-layout/subscriber.js +++ b/react/features/video-layout/subscriber.js @@ -97,19 +97,20 @@ function _getAutoPinSetting() { function _updateAutoPinnedParticipant({ dispatch, getState }) { const state = getState(); const remoteScreenShares = state['features/video-layout'].remoteScreenShares; + const pinned = getPinnedParticipant(getState); + + // Unpin the screenshare when the screensharing participant has left. + if (!remoteScreenShares?.length) { + const participantId = pinned ? pinned.id : null; + + dispatch(pinParticipant(participantId)); - if (!remoteScreenShares) { return; } - const latestScreenshareParticipantId - = remoteScreenShares[remoteScreenShares.length - 1]; - - const pinned = getPinnedParticipant(getState); + const latestScreenshareParticipantId = remoteScreenShares[remoteScreenShares.length - 1]; if (latestScreenshareParticipantId) { dispatch(pinParticipant(latestScreenshareParticipantId)); - } else if (pinned) { - dispatch(pinParticipant(null)); } }