You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.web.ts 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
  2. import { getLocalParticipant } from '../base/participants/functions';
  3. import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
  4. import { setDisableButton } from './actions.web';
  5. import { SHARED_VIDEO } from './constants';
  6. import './middleware.any';
  7. MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
  8. const state = getState();
  9. const localParticipantId = getLocalParticipant(state)?.id;
  10. switch (action.type) {
  11. case CONFERENCE_JOIN_IN_PROGRESS: {
  12. const { conference } = action;
  13. conference.addCommandListener(SHARED_VIDEO, ({ attributes }: { attributes:
  14. { from: string; state: string; }; }) => {
  15. const { from } = attributes;
  16. const status = attributes.state;
  17. if (status === 'playing') {
  18. if (localParticipantId !== from) {
  19. dispatch(setDisableButton(true));
  20. }
  21. } else if (status === 'stop') {
  22. dispatch(setDisableButton(false));
  23. }
  24. });
  25. break;
  26. }
  27. }
  28. return next(action);
  29. });