fix(video-layout): Unpin SS when the screensharing participant leaves.

This commit is contained in:
Jaya Allamsetty 2021-04-15 16:12:31 -04:00 committed by Jaya Allamsetty
parent 289ba6f764
commit c12c554138
1 changed files with 8 additions and 7 deletions

View File

@ -97,19 +97,20 @@ function _getAutoPinSetting() {
function _updateAutoPinnedParticipant({ dispatch, getState }) { function _updateAutoPinnedParticipant({ dispatch, getState }) {
const state = getState(); const state = getState();
const remoteScreenShares = state['features/video-layout'].remoteScreenShares; 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; return;
} }
const latestScreenshareParticipantId const latestScreenshareParticipantId = remoteScreenShares[remoteScreenShares.length - 1];
= remoteScreenShares[remoteScreenShares.length - 1];
const pinned = getPinnedParticipant(getState);
if (latestScreenshareParticipantId) { if (latestScreenshareParticipantId) {
dispatch(pinParticipant(latestScreenshareParticipantId)); dispatch(pinParticipant(latestScreenshareParticipantId));
} else if (pinned) {
dispatch(pinParticipant(null));
} }
} }