2021-03-03 14:37:38 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { getCurrentConference } from '../base/conference';
|
|
|
|
import { getLocalParticipant } from '../base/participants';
|
2021-04-16 09:43:34 +00:00
|
|
|
import { StateListenerRegistry } from '../base/redux';
|
2021-03-03 14:37:38 +00:00
|
|
|
|
|
|
|
import { setDisableButton } from './actions.web';
|
|
|
|
import { SHARED_VIDEO } from './constants';
|
|
|
|
|
2021-04-16 09:43:34 +00:00
|
|
|
import './middleware.any';
|
2021-03-03 14:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up state change listener to disable or enable the share video button in
|
|
|
|
* the toolbar menu.
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
state => getCurrentConference(state),
|
|
|
|
(conference, store, previousConference) => {
|
|
|
|
if (conference && conference !== previousConference) {
|
|
|
|
conference.addCommandListener(SHARED_VIDEO,
|
|
|
|
({ attributes }) => {
|
|
|
|
const { dispatch, getState } = store;
|
|
|
|
const { from } = attributes;
|
|
|
|
const localParticipantId = getLocalParticipant(getState()).id;
|
|
|
|
const status = attributes.state;
|
|
|
|
|
|
|
|
if (status === 'playing') {
|
|
|
|
if (localParticipantId !== from) {
|
|
|
|
dispatch(setDisableButton(true));
|
|
|
|
}
|
|
|
|
} else if (status === 'stop') {
|
|
|
|
dispatch(setDisableButton(false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|