選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

middleware.js 2.9KB

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