您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

reducer.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. CLEAR_TOOLBOX_TIMEOUT,
  5. FULL_SCREEN_CHANGED,
  6. SET_TOOLBAR_HOVERED,
  7. SET_TOOLBOX_ALWAYS_VISIBLE,
  8. SET_TOOLBOX_ENABLED,
  9. SET_TOOLBOX_TIMEOUT,
  10. SET_TOOLBOX_TIMEOUT_MS,
  11. SET_TOOLBOX_VISIBLE
  12. } from './actionTypes';
  13. declare var interfaceConfig: Object;
  14. /**
  15. * Returns initial state for toolbox's part of Redux store.
  16. *
  17. * @private
  18. * @returns {{
  19. * alwaysVisible: boolean,
  20. * enabled: boolean,
  21. * hovered: boolean,
  22. * timeoutID: number,
  23. * timeoutMS: number,
  24. * visible: boolean
  25. * }}
  26. */
  27. function _getInitialState() {
  28. // Default toolbox timeout for mobile app.
  29. let timeoutMS = 5000;
  30. if (typeof interfaceConfig !== 'undefined'
  31. && interfaceConfig.INITIAL_TOOLBAR_TIMEOUT) {
  32. timeoutMS = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  33. }
  34. return {
  35. /**
  36. * The indicator which determines whether the Toolbox should always be
  37. * visible.
  38. *
  39. * @type {boolean}
  40. */
  41. alwaysVisible: false,
  42. /**
  43. * The indicator which determines whether the Toolbox is enabled. For
  44. * example, modules/UI/recording/Recording.js disables the Toolbox.
  45. *
  46. * @type {boolean}
  47. */
  48. enabled: true,
  49. /**
  50. * The indicator which determines whether a Toolbar in the Toolbox is
  51. * hovered.
  52. *
  53. * @type {boolean}
  54. */
  55. hovered: false,
  56. /**
  57. * A number, non-zero value which identifies the timer created by a call
  58. * to setTimeout() with timeoutMS.
  59. *
  60. * @type {number|null}
  61. */
  62. timeoutID: null,
  63. /**
  64. * The delay in milliseconds before timeoutID executes (after its
  65. * initialization).
  66. *
  67. * @type {number}
  68. */
  69. timeoutMS,
  70. /**
  71. * The indicator which determines whether the Toolbox is visible.
  72. *
  73. * @type {boolean}
  74. */
  75. visible: false
  76. };
  77. }
  78. ReducerRegistry.register(
  79. 'features/toolbox',
  80. (state: Object = _getInitialState(), action: Object) => {
  81. switch (action.type) {
  82. case CLEAR_TOOLBOX_TIMEOUT:
  83. return {
  84. ...state,
  85. timeoutID: undefined
  86. };
  87. case FULL_SCREEN_CHANGED:
  88. return {
  89. ...state,
  90. fullScreen: action.fullScreen
  91. };
  92. case SET_TOOLBAR_HOVERED:
  93. return {
  94. ...state,
  95. hovered: action.hovered
  96. };
  97. case SET_TOOLBOX_ALWAYS_VISIBLE:
  98. return {
  99. ...state,
  100. alwaysVisible: action.alwaysVisible
  101. };
  102. case SET_TOOLBOX_ENABLED:
  103. return {
  104. ...state,
  105. enabled: action.enabled
  106. };
  107. case SET_TOOLBOX_TIMEOUT:
  108. return {
  109. ...state,
  110. timeoutID: action.timeoutID,
  111. timeoutMS: action.timeoutMS
  112. };
  113. case SET_TOOLBOX_TIMEOUT_MS:
  114. return {
  115. ...state,
  116. timeoutMS: action.timeoutMS
  117. };
  118. case SET_TOOLBOX_VISIBLE:
  119. return {
  120. ...state,
  121. visible: action.visible
  122. };
  123. }
  124. return state;
  125. });