Files
jitsi-meet/react/features/shared-video/middleware.web.ts
Дамян Минков 3f7c3b8fd2 feat(shared-video): Shows confirmation dialog before playing video. (#15059)
* feat(shared-video): Shows confirmation dialog before playing video.

* feat(shared-video/native): created ShareVideoConfirmDialog and unified actions

* squash: Simplifies state and fixes stop and then start scenario.

* squash: Use constants everywhere.

* squash: Use helper function.

* squash: Ignore any command with not matching video URL.

---------

Co-authored-by: Calin-Teodor <calin.chitu@8x8.com>
2024-08-27 10:45:39 -05:00

42 lines
1.3 KiB
TypeScript

import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
import { getLocalParticipant } from '../base/participants/functions';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { setDisableButton } from './actions.web';
import { PLAYBACK_STATUSES, SHARED_VIDEO } from './constants';
import { isSharedVideoEnabled } from './functions';
import './middleware.any';
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const state = getState();
const localParticipantId = getLocalParticipant(state)?.id;
switch (action.type) {
case CONFERENCE_JOIN_IN_PROGRESS: {
if (!isSharedVideoEnabled(state)) {
break;
}
const { conference } = action;
conference.addCommandListener(SHARED_VIDEO, ({ attributes }: { attributes:
{ from: string; state: string; }; }) => {
const { from } = attributes;
const status = attributes.state;
if (status === PLAYBACK_STATUSES.PLAYING) {
if (localParticipantId !== from) {
dispatch(setDisableButton(true));
}
} else if (status === 'stop') {
dispatch(setDisableButton(false));
}
});
break;
}
}
return next(action);
});