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 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // @flow
  2. import { getCurrentConference } from '../base/conference';
  3. import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
  4. import { SET_E2EE_KEY } from './actionTypes';
  5. import { setE2EEKey } from './actions';
  6. import logger from './logger';
  7. /**
  8. * Middleware that captures actions related to E2EE.
  9. *
  10. * @param {Store} store - The redux store.
  11. * @returns {Function}
  12. */
  13. MiddlewareRegistry.register(({ getState }) => next => action => {
  14. switch (action.type) {
  15. case SET_E2EE_KEY: {
  16. const conference = getCurrentConference(getState);
  17. if (conference) {
  18. logger.debug(`New E2EE key: ${action.key}`);
  19. conference.setE2EEKey(action.key);
  20. }
  21. break;
  22. }
  23. }
  24. return next(action);
  25. });
  26. /**
  27. * Set up state change listener to perform maintenance tasks when the conference
  28. * is left or failed.
  29. */
  30. StateListenerRegistry.register(
  31. state => getCurrentConference(state),
  32. (conference, { dispatch }, previousConference) => {
  33. if (previousConference) {
  34. dispatch(setE2EEKey(undefined));
  35. }
  36. });