Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

reducer.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // @flow
  2. import { PARTICIPANT_LEFT } from '../base/participants';
  3. import { ReducerRegistry } from '../base/redux';
  4. import {
  5. SET_FILMSTRIP_ENABLED,
  6. SET_FILMSTRIP_VISIBLE,
  7. SET_HORIZONTAL_VIEW_DIMENSIONS,
  8. SET_REMOTE_PARTICIPANTS,
  9. SET_TILE_VIEW_DIMENSIONS,
  10. SET_VERTICAL_VIEW_DIMENSIONS,
  11. SET_VISIBLE_REMOTE_PARTICIPANTS,
  12. SET_VOLUME
  13. } from './actionTypes';
  14. const DEFAULT_STATE = {
  15. /**
  16. * The indicator which determines whether the {@link Filmstrip} is enabled.
  17. *
  18. * @public
  19. * @type {boolean}
  20. */
  21. enabled: true,
  22. /**
  23. * The horizontal view dimensions.
  24. *
  25. * @public
  26. * @type {Object}
  27. */
  28. horizontalViewDimensions: {},
  29. /**
  30. * The custom audio volume levels per participant.
  31. *
  32. * @type {Object}
  33. */
  34. participantsVolume: {},
  35. /**
  36. * The ordered IDs of the remote participants displayed in the filmstrip.
  37. *
  38. * @public
  39. * @type {Array<string>}
  40. */
  41. remoteParticipants: [],
  42. /**
  43. * The tile view dimensions.
  44. *
  45. * @public
  46. * @type {Object}
  47. */
  48. tileViewDimensions: {},
  49. /**
  50. * The vertical view dimensions.
  51. *
  52. * @public
  53. * @type {Object}
  54. */
  55. verticalViewDimensions: {},
  56. /**
  57. * The indicator which determines whether the {@link Filmstrip} is visible.
  58. *
  59. * @public
  60. * @type {boolean}
  61. */
  62. visible: true,
  63. /**
  64. * The end index in the remote participants array that is visible in the filmstrip.
  65. *
  66. * @public
  67. * @type {number}
  68. */
  69. visibleParticipantsEndIndex: 0,
  70. /**
  71. * The start index in the remote participants array that is visible in the filmstrip.
  72. *
  73. * @public
  74. * @type {number}
  75. */
  76. visibleParticipantsStartIndex: 0,
  77. /**
  78. * The visible remote participants in the filmstrip.
  79. *
  80. * @public
  81. * @type {Set<string>}
  82. */
  83. visibleRemoteParticipants: new Set()
  84. };
  85. ReducerRegistry.register(
  86. 'features/filmstrip',
  87. (state = DEFAULT_STATE, action) => {
  88. switch (action.type) {
  89. case SET_FILMSTRIP_ENABLED:
  90. return {
  91. ...state,
  92. enabled: action.enabled
  93. };
  94. case SET_FILMSTRIP_VISIBLE:
  95. return {
  96. ...state,
  97. visible: action.visible
  98. };
  99. case SET_HORIZONTAL_VIEW_DIMENSIONS:
  100. return {
  101. ...state,
  102. horizontalViewDimensions: action.dimensions
  103. };
  104. case SET_REMOTE_PARTICIPANTS: {
  105. state.remoteParticipants = action.participants;
  106. const { visibleParticipantsStartIndex: startIndex, visibleParticipantsEndIndex: endIndex } = state;
  107. state.visibleRemoteParticipants = new Set(state.remoteParticipants.slice(startIndex, endIndex + 1));
  108. return { ...state };
  109. }
  110. case SET_TILE_VIEW_DIMENSIONS:
  111. return {
  112. ...state,
  113. tileViewDimensions: action.dimensions
  114. };
  115. case SET_VERTICAL_VIEW_DIMENSIONS:
  116. return {
  117. ...state,
  118. verticalViewDimensions: action.dimensions
  119. };
  120. case SET_VOLUME:
  121. return {
  122. ...state,
  123. participantsVolume: {
  124. ...state.participantsVolume,
  125. // NOTE: This would fit better in the features/base/participants. But currently we store
  126. // the participants as an array which will make it expensive to search for the volume for
  127. // every participant separately.
  128. [action.participantId]: action.volume
  129. }
  130. };
  131. case SET_VISIBLE_REMOTE_PARTICIPANTS: {
  132. return {
  133. ...state,
  134. visibleParticipantsStartIndex: action.startIndex,
  135. visibleParticipantsEndIndex: action.endIndex,
  136. visibleRemoteParticipants:
  137. new Set(state.remoteParticipants.slice(action.startIndex, action.endIndex + 1))
  138. };
  139. }
  140. case PARTICIPANT_LEFT: {
  141. const { id, local } = action.participant;
  142. if (local) {
  143. return state;
  144. }
  145. delete state.participantsVolume[id];
  146. return {
  147. ...state
  148. };
  149. }
  150. }
  151. return state;
  152. });