2022-04-06 02:13:39 +00:00
|
|
|
import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
|
2022-10-28 06:41:12 +00:00
|
|
|
import { getLocalParticipant } from '../base/participants/functions';
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
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
|
|
|
|
2022-04-06 02:13:39 +00:00
|
|
|
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
|
|
|
const state = getState();
|
|
|
|
const localParticipantId = getLocalParticipant(state)?.id;
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
case CONFERENCE_JOIN_IN_PROGRESS: {
|
|
|
|
const { conference } = action;
|
|
|
|
|
2022-10-28 06:41:12 +00:00
|
|
|
conference.addCommandListener(SHARED_VIDEO, ({ attributes }: { attributes:
|
|
|
|
{ from: string; state: string; }; }) => {
|
2022-04-06 02:13:39 +00:00
|
|
|
const { from } = attributes;
|
|
|
|
const status = attributes.state;
|
|
|
|
|
|
|
|
if (status === 'playing') {
|
|
|
|
if (localParticipantId !== from) {
|
|
|
|
dispatch(setDisableButton(true));
|
2021-03-03 14:37:38 +00:00
|
|
|
}
|
2022-04-06 02:13:39 +00:00
|
|
|
} else if (status === 'stop') {
|
|
|
|
dispatch(setDisableButton(false));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
break;
|
2021-03-03 14:37:38 +00:00
|
|
|
}
|
2022-04-06 02:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|