Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

reducer.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { ReducerRegistry } from '../redux';
  2. import {
  3. CONFERENCE_JOINED,
  4. CONFERENCE_LEFT,
  5. CONFERENCE_WILL_LEAVE,
  6. SET_ROOM
  7. } from './actionTypes';
  8. import { isRoomValid } from './functions';
  9. const INITIAL_STATE = {
  10. jitsiConference: null,
  11. /**
  12. * Instance of JitsiConference that is currently in 'leaving' state.
  13. */
  14. leavingJitsiConference: null,
  15. /**
  16. * The name of the room of the conference (to be) joined (i.e.
  17. * {@link #jitsiConference}).
  18. *
  19. * @type {string}
  20. */
  21. room: null
  22. };
  23. /**
  24. * Listen for actions that contain the conference object, so that it can be
  25. * stored for use by other action creators.
  26. */
  27. ReducerRegistry.register('features/base/conference',
  28. (state = INITIAL_STATE, action) => {
  29. switch (action.type) {
  30. case CONFERENCE_JOINED:
  31. return {
  32. ...state,
  33. jitsiConference: action.conference.jitsiConference
  34. };
  35. case CONFERENCE_LEFT:
  36. if (state.jitsiConference === action.conference.jitsiConference) {
  37. return {
  38. ...state,
  39. jitsiConference: null,
  40. leavingJitsiConference: state.leavingJitsiConference
  41. === action.conference.jitsiConference
  42. ? null
  43. : state.leavingJitsiConference
  44. };
  45. }
  46. break;
  47. case CONFERENCE_WILL_LEAVE:
  48. return {
  49. ...state,
  50. leavingJitsiConference: action.conference.jitsiConference
  51. };
  52. case SET_ROOM: {
  53. let room = action.room;
  54. // Technically, there're multiple values which don't represent
  55. // valid room names. Practically, each of them is as bad as the rest
  56. // of them because we can't use any of them to join a conference.
  57. if (!isRoomValid(room)) {
  58. room = INITIAL_STATE.room;
  59. }
  60. if (state.room !== room) {
  61. return {
  62. ...state,
  63. room
  64. };
  65. }
  66. break;
  67. }
  68. }
  69. return state;
  70. });