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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // @flow
  2. import { SET_ROOM } from '../../base/conference/actionTypes';
  3. import { MiddlewareRegistry } from '../../base/redux';
  4. import { navigateRoot } from './rootNavigationContainerRef';
  5. import { screen } from './routes';
  6. MiddlewareRegistry.register(store => next => action => {
  7. switch (action.type) {
  8. case SET_ROOM:
  9. return _setRoom(store, next, action);
  10. }
  11. return next(action);
  12. });
  13. /**
  14. * Notifies the feature base/conference that the action
  15. * {@code SET_ROOM} is being dispatched within a specific
  16. * redux store.
  17. *
  18. * @param {Store} store - The redux store in which the specified {@code action}
  19. * is being dispatched.
  20. * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
  21. * specified {@code action} to the specified {@code store}.
  22. * @param {Action} action - The redux action {@code SET_ROOM}
  23. * which is being dispatched in the specified {@code store}.
  24. * @private
  25. * @returns {Object} The value returned by {@code next(action)}.
  26. */
  27. function _setRoom(store, next, action) {
  28. const { room: oldRoom } = store.getState()['features/base/conference'];
  29. const result = next(action);
  30. const { room: newRoom } = store.getState()['features/base/conference'];
  31. if (!oldRoom && newRoom) {
  32. navigateRoot(screen.conference.root);
  33. } else if (oldRoom && !newRoom) {
  34. navigateRoot(screen.root);
  35. }
  36. return result;
  37. }