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.js 807B

1234567891011121314151617181920212223242526272829
  1. import {
  2. CONFERENCE_JOINED,
  3. CONFERENCE_LEFT
  4. } from '../conference';
  5. import { MiddlewareRegistry } from '../redux';
  6. import { localParticipantIdChanged } from './actions';
  7. import { LOCAL_PARTICIPANT_DEFAULT_ID } from './constants';
  8. /**
  9. * Middleware that captures CONFERENCE_JOINED and CONFERENCE_LEFT actions and
  10. * updates respectively ID of local participant.
  11. *
  12. * @param {Store} store - Redux store.
  13. * @returns {Function}
  14. */
  15. MiddlewareRegistry.register(store => next => action => {
  16. switch (action.type) {
  17. case CONFERENCE_JOINED:
  18. store.dispatch(localParticipantIdChanged(action.conference.myUserId()));
  19. break;
  20. case CONFERENCE_LEFT:
  21. store.dispatch(localParticipantIdChanged(LOCAL_PARTICIPANT_DEFAULT_ID));
  22. break;
  23. }
  24. return next(action);
  25. });