fix(pinning): dynamically check auto-pin setting

Any overrides set on interfaceConfig are not
applied on module load. As such, call to get
the value of the auto pin setting, providing
time for the bootstrapping to set overrides.
Otherwise iframe api users cannot override
the setting.
This commit is contained in:
Leonard Kim 2019-08-22 15:22:09 -07:00 committed by virtuacoplenny
parent 5a934c071a
commit af2c61fd96
1 changed files with 18 additions and 8 deletions

View File

@ -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.