Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

middleware.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // @flow
  2. import { appNavigate } from '../app';
  3. import {
  4. CONFERENCE_JOINED,
  5. KICKED_OUT,
  6. VIDEO_QUALITY_LEVELS,
  7. conferenceFailed,
  8. getCurrentConference,
  9. setPreferredReceiverVideoQuality
  10. } from '../base/conference';
  11. import { hideDialog, isDialogOpen } from '../base/dialog';
  12. import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
  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(
  39. conferenceFailed(action.conference, JitsiConferenceEvents.KICKED));
  40. dispatch(appNavigate(undefined));
  41. break;
  42. }
  43. }
  44. return result;
  45. });
  46. /**
  47. * Set up state change listener to perform maintenance tasks when the conference
  48. * is left or failed, close all dialogs and unpin any pinned participants.
  49. */
  50. StateListenerRegistry.register(
  51. state => getCurrentConference(state),
  52. (conference, { dispatch, getState }, prevConference) => {
  53. const { authRequired, passwordRequired }
  54. = getState()['features/base/conference'];
  55. if (conference !== prevConference) {
  56. // Unpin participant, in order to avoid the local participant
  57. // remaining pinned, since it's not destroyed across runs.
  58. dispatch(pinParticipant(null));
  59. // XXX I wonder if there is a better way to do this. At this stage
  60. // we do know what dialogs we want to keep but the list of those
  61. // we want to hide is a lot longer. Thus we take a bit of a shortcut
  62. // and explicitly check.
  63. if (typeof authRequired === 'undefined'
  64. && typeof passwordRequired === 'undefined'
  65. && !isDialogOpen(getState(), FeedbackDialog)) {
  66. // Conference changed, left or failed... and there is no
  67. // pending authentication, nor feedback request, so close any
  68. // dialog we might have open.
  69. dispatch(hideDialog());
  70. }
  71. }
  72. });