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

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