Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

squash: use oldScreenSharesOrder for checking.

Jaya Allamsetty1c6677f52325
diff --git a/react/features/video-layout/subscriber.js b/react/features/video-layout/subscriber.js
index 02467ecf76..1b5d28710b 100644
--- a/react/features/video-layout/subscriber.js
+++ b/react/features/video-layout/subscriber.js
@@ -12,8 +12,6 @@ import { setRemoteParticipantsWithScreenShare } from './actions';
declare var APP: Object;
declare var interfaceConfig: Object;
-let latestScreenshareParticipantId;
-
/**
* StateListenerRegistry provides a reliable way of detecting changes to
* preferred layout state and dispatching additional actions.
@@ -70,7 +68,7 @@ StateListenerRegistry.register(
store.dispatch(
setRemoteParticipantsWithScreenShare(newScreenSharesOrder));
- _updateAutoPinnedParticipant(store);
+ _updateAutoPinnedParticipant(oldScreenSharesOrder, store);
}
}, 100));
@@ -93,10 +91,12 @@ function _getAutoPinSetting() {
* Private helper to automatically pin the latest screen share stream or unpin
* if there are no more screen share streams.
*
+ * @param {Array<string>} screenShares - Array containing the list of all the screensharing endpoints
+ * before the update was triggered (including the ones that have been removed from redux because of the update).
* @param {Store} store - The redux store.
* @returns {void}
*/
-function _updateAutoPinnedParticipant({ dispatch, getState }) {
+function _updateAutoPinnedParticipant(screenShares, { dispatch, getState }) {
const state = getState();
const remoteScreenShares = state['features/video-layout'].remoteScreenShares;
const pinned = getPinnedParticipant(getState);
@@ -106,17 +106,15 @@ function _updateAutoPinnedParticipant({ dispatch, getState }) {
if (!remoteScreenShares?.length) {
let participantId = null;
- if (pinned && pinned.id !== latestScreenshareParticipantId) {
+ if (pinned && !screenShares.find(share => share === pinned.id)) {
participantId = pinned.id;
}
-
- latestScreenshareParticipantId = null;
dispatch(pinParticipant(participantId));
return;
}
- latestScreenshareParticipantId = remoteScreenShares[remoteScreenShares.length - 1];
+ const latestScreenshareParticipantId = remoteScreenShares[remoteScreenShares.length - 1];
if (latestScreenshareParticipantId) {
dispatch(pinParticipant(latestScreenshareParticipantId));