jiti-meet/react/features/remote-control/subscriber.js

55 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-11-14 04:09:25 +00:00
// @flow
import {
getParticipantById,
getVirtualScreenshareParticipantByOwnerId,
getVirtualScreenshareParticipantOwnerId
} from '../base/participants';
2020-11-14 04:09:25 +00:00
import { StateListenerRegistry } from '../base/redux';
import { pause, resume } from './actions';
2020-11-14 04:09:25 +00:00
/**
* Listens for large video participant ID changes.
*/
StateListenerRegistry.register(
/* selector */ state => {
const { participantId } = state['features/large-video'];
const { controller } = state['features/remote-control'];
const { controlled } = controller;
if (!controlled) {
return undefined;
}
const participant = getParticipantById(state, participantId);
if (participant?.isVirtualScreenshareParticipant) {
// multistream support is enabled and the user has selected the desktop sharing thumbnail.
const id = getVirtualScreenshareParticipantOwnerId(participantId);
return id === controlled;
}
const virtualParticipant = getVirtualScreenshareParticipantByOwnerId(state, participantId);
if (virtualParticipant) { // multistream is enabled and the user has selected the camera thumbnail.
return false;
}
2020-11-14 04:09:25 +00:00
return controlled === participantId;
},
/* listener */ (isControlledParticipantOnStage, { dispatch }) => {
if (isControlledParticipantOnStage === true) {
dispatch(resume());
} else if (isControlledParticipantOnStage === false) {
dispatch(pause());
}
// else {
// isControlledParticipantOnStage === undefined. Ignore!
// }
}
);