Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

reducer.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. CLEAR_TOOLBOX_TIMEOUT,
  5. FULL_SCREEN_CHANGED,
  6. SET_DEFAULT_TOOLBOX_BUTTONS,
  7. SET_SUBJECT,
  8. SET_SUBJECT_SLIDE_IN,
  9. SET_TOOLBAR_HOVERED,
  10. SET_TOOLBOX_ALWAYS_VISIBLE,
  11. SET_TOOLBOX_ENABLED,
  12. SET_TOOLBOX_TIMEOUT,
  13. SET_TOOLBOX_TIMEOUT_MS,
  14. SET_TOOLBOX_VISIBLE
  15. } from './actionTypes';
  16. declare var interfaceConfig: Object;
  17. /**
  18. * Returns initial state for toolbox's part of Redux store.
  19. *
  20. * @private
  21. * @returns {{
  22. * alwaysVisible: boolean,
  23. * hovered: boolean,
  24. * primaryToolbarButtons: Map,
  25. * secondaryToolbarButtons: Map,
  26. * subject: string,
  27. * subjectSlideIn: boolean,
  28. * timeoutID: number,
  29. * timeoutMS: number,
  30. * visible: boolean
  31. * }}
  32. */
  33. function _getInitialState() {
  34. // Default toolbox timeout for mobile app.
  35. let timeoutMS = 5000;
  36. if (typeof interfaceConfig !== 'undefined'
  37. && interfaceConfig.INITIAL_TOOLBAR_TIMEOUT) {
  38. timeoutMS = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  39. }
  40. return {
  41. /**
  42. * The indicator which determines whether the Toolbox should always be
  43. * visible.
  44. *
  45. * @type {boolean}
  46. */
  47. alwaysVisible: false,
  48. /**
  49. * The indicator which determines whether the Toolbox is enabled. For
  50. * example, modules/UI/recording/Recording.js disables the Toolbox.
  51. *
  52. * @type {boolean}
  53. */
  54. enabled: true,
  55. /**
  56. * The indicator which determines whether a Toolbar in the Toolbox is
  57. * hovered.
  58. *
  59. * @type {boolean}
  60. */
  61. hovered: false,
  62. /**
  63. * A Map of the default buttons of the PrimaryToolbar.
  64. *
  65. * @type {Map}
  66. */
  67. primaryToolbarButtons: new Map(),
  68. /**
  69. * A Map of the default buttons of the SecondaryToolbar.
  70. *
  71. * @type {Map}
  72. */
  73. secondaryToolbarButtons: new Map(),
  74. /**
  75. * The text of the conference subject.
  76. *
  77. * @type {string}
  78. */
  79. subject: '',
  80. /**
  81. * The indicator which determines whether the subject is sliding in.
  82. *
  83. * @type {boolean}
  84. */
  85. subjectSlideIn: false,
  86. /**
  87. * A number, non-zero value which identifies the timer created by a call
  88. * to setTimeout() with timeoutMS.
  89. *
  90. * @type {number|null}
  91. */
  92. timeoutID: null,
  93. /**
  94. * The delay in milliseconds before timeoutID executes (after its
  95. * initialization).
  96. *
  97. * @type {number}
  98. */
  99. timeoutMS,
  100. /**
  101. * The indicator which determines whether the Toolbox is visible.
  102. *
  103. * @type {boolean}
  104. */
  105. visible: false
  106. };
  107. }
  108. ReducerRegistry.register(
  109. 'features/toolbox',
  110. (state: Object = _getInitialState(), action: Object) => {
  111. switch (action.type) {
  112. case CLEAR_TOOLBOX_TIMEOUT:
  113. return {
  114. ...state,
  115. timeoutID: undefined
  116. };
  117. case FULL_SCREEN_CHANGED:
  118. return {
  119. ...state,
  120. fullScreen: action.fullScreen
  121. };
  122. case SET_DEFAULT_TOOLBOX_BUTTONS: {
  123. const { primaryToolbarButtons, secondaryToolbarButtons } = action;
  124. return {
  125. ...state,
  126. primaryToolbarButtons,
  127. secondaryToolbarButtons
  128. };
  129. }
  130. case SET_SUBJECT:
  131. return {
  132. ...state,
  133. subject: action.subject
  134. };
  135. case SET_SUBJECT_SLIDE_IN:
  136. return {
  137. ...state,
  138. subjectSlideIn: action.subjectSlideIn
  139. };
  140. case SET_TOOLBAR_HOVERED:
  141. return {
  142. ...state,
  143. hovered: action.hovered
  144. };
  145. case SET_TOOLBOX_ALWAYS_VISIBLE:
  146. return {
  147. ...state,
  148. alwaysVisible: action.alwaysVisible
  149. };
  150. case SET_TOOLBOX_ENABLED:
  151. return {
  152. ...state,
  153. enabled: action.enabled
  154. };
  155. case SET_TOOLBOX_TIMEOUT:
  156. return {
  157. ...state,
  158. timeoutID: action.timeoutID,
  159. timeoutMS: action.timeoutMS
  160. };
  161. case SET_TOOLBOX_TIMEOUT_MS:
  162. return {
  163. ...state,
  164. timeoutMS: action.timeoutMS
  165. };
  166. case SET_TOOLBOX_VISIBLE:
  167. return {
  168. ...state,
  169. visible: action.visible
  170. };
  171. }
  172. return state;
  173. });