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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // @flow
  2. import { notifyKickedOut } from './actions';
  3. import { appNavigate } from '../app';
  4. import {
  5. CONFERENCE_JOINED,
  6. KICKED_OUT,
  7. VIDEO_QUALITY_LEVELS,
  8. conferenceLeft,
  9. getCurrentConference,
  10. setPreferredReceiverVideoQuality
  11. } from '../base/conference';
  12. import { hideDialog, isDialogOpen } from '../base/dialog';
  13. import { pinParticipant } from '../base/participants';
  14. import { SET_REDUCED_UI } from '../base/responsive-ui';
  15. import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
  16. import { FeedbackDialog } from '../feedback';
  17. import { setFilmstripEnabled } from '../filmstrip';
  18. import { setToolboxEnabled } from '../toolbox';
  19. MiddlewareRegistry.register(store => next => action => {
  20. const result = next(action);
  21. switch (action.type) {
  22. case CONFERENCE_JOINED:
  23. case SET_REDUCED_UI: {
  24. const { dispatch, getState } = store;
  25. const state = getState();
  26. const { reducedUI } = state['features/base/responsive-ui'];
  27. dispatch(setToolboxEnabled(!reducedUI));
  28. dispatch(setFilmstripEnabled(!reducedUI));
  29. dispatch(
  30. setPreferredReceiverVideoQuality(
  31. reducedUI
  32. ? VIDEO_QUALITY_LEVELS.LOW
  33. : VIDEO_QUALITY_LEVELS.HIGH));
  34. break;
  35. }
  36. case KICKED_OUT: {
  37. const { dispatch } = store;
  38. dispatch(notifyKickedOut(
  39. action.participant,
  40. () => {
  41. dispatch(conferenceLeft(action.conference));
  42. dispatch(appNavigate(undefined));
  43. }
  44. ));
  45. break;
  46. }
  47. }
  48. return result;
  49. });
  50. /**
  51. * Set up state change listener to perform maintenance tasks when the conference
  52. * is left or failed, close all dialogs and unpin any pinned participants.
  53. */
  54. StateListenerRegistry.register(
  55. state => getCurrentConference(state),
  56. (conference, { dispatch, getState }, prevConference) => {
  57. const { authRequired, passwordRequired }
  58. = getState()['features/base/conference'];
  59. if (conference !== prevConference) {
  60. // Unpin participant, in order to avoid the local participant
  61. // remaining pinned, since it's not destroyed across runs.
  62. dispatch(pinParticipant(null));
  63. // XXX I wonder if there is a better way to do this. At this stage
  64. // we do know what dialogs we want to keep but the list of those
  65. // we want to hide is a lot longer. Thus we take a bit of a shortcut
  66. // and explicitly check.
  67. if (typeof authRequired === 'undefined'
  68. && typeof passwordRequired === 'undefined'
  69. && !isDialogOpen(getState(), FeedbackDialog)) {
  70. // Conference changed, left or failed... and there is no
  71. // pending authentication, nor feedback request, so close any
  72. // dialog we might have open.
  73. dispatch(hideDialog());
  74. }
  75. }
  76. });