Skip to content

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

fix(pinning): dynamically check auto-pin setting

Leonard Kimaf2c61fd961a
diff --git a/react/features/video-layout/subscriber.js b/react/features/video-layout/subscriber.js
index 9eff5138ff..d80ab6469a 100644
--- a/react/features/video-layout/subscriber.js
+++ b/react/features/video-layout/subscriber.js
@@ -18,10 +18,6 @@ import { setParticipantsWithScreenShare } from './actions';
declare var APP: Object;
declare var interfaceConfig: Object;
-// TODO: interfaceConfig should be in redux so we didn't have to do this.
-const AUTO_PIN_LATEST_SCREEN_SHARE
- = typeof interfaceConfig === 'object' ? interfaceConfig.AUTO_PIN_LATEST_SCREEN_SHARE : 'remote-only';
-
/**
* StateListenerRegistry provides a reliable way of detecting changes to
* preferred layout state and dispatching additional actions.
@@ -37,7 +33,7 @@ StateListenerRegistry.register(
dispatch(
setMaxReceiverVideoQuality(VIDEO_QUALITY_LEVELS.HIGH));
- if (AUTO_PIN_LATEST_SCREEN_SHARE) {
+ if (_getAutoPinSetting()) {
_updateAutoPinnedParticipant(store);
}
}
@@ -52,7 +48,7 @@ StateListenerRegistry.register(
StateListenerRegistry.register(
/* selector */ state => state['features/base/tracks'],
/* listener */ debounce((tracks, store) => {
- if (!AUTO_PIN_LATEST_SCREEN_SHARE) {
+ if (!_getAutoPinSetting()) {
return;
}
@@ -60,8 +56,7 @@ StateListenerRegistry.register(
= store.getState()['features/video-layout'].screenShares || [];
const knownSharingParticipantIds = tracks.reduce((acc, track) => {
if (track.mediaType === 'video' && track.videoType === 'desktop') {
- const skipTrack
- = AUTO_PIN_LATEST_SCREEN_SHARE === 'remote-only' && track.local;
+ const skipTrack = _getAutoPinSetting() === 'remote-only' && track.local;
if (!skipTrack) {
acc.push(track.participantId);
@@ -93,6 +88,21 @@ StateListenerRegistry.register(
}
}, 100));
+/**
+ * A selector for retrieving the current automatic pinning setting.
+ *
+ * @private
+ * @returns {string|undefined} The string "remote-only" is returned if only
+ * remote screensharing should be automatically pinned, any other truthy value
+ * means automatically pin all screenshares. Falsy means do not automatically
+ * pin any screenshares.
+ */
+function _getAutoPinSetting() {
+ return typeof interfaceConfig === 'object'
+ ? interfaceConfig.AUTO_PIN_LATEST_SCREEN_SHARE
+ : 'remote-only';
+}
+
/**
* Private helper to automatically pin the latest screen share stream or unpin
* if there are no more screen share streams.