You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // @flow
  2. import { ReducerRegistry, set } from '../base/redux';
  3. import {
  4. CLEAR_TOOLBOX_TIMEOUT,
  5. FULL_SCREEN_CHANGED,
  6. SET_HANGUP_MENU_VISIBLE,
  7. SET_OVERFLOW_DRAWER,
  8. SET_OVERFLOW_MENU_VISIBLE,
  9. SET_TOOLBAR_HOVERED,
  10. SET_TOOLBOX_ENABLED,
  11. SET_TOOLBOX_TIMEOUT,
  12. SET_TOOLBOX_VISIBLE,
  13. TOGGLE_TOOLBOX_VISIBLE
  14. } from './actionTypes';
  15. /**
  16. * Initial state of toolbox's part of Redux store.
  17. */
  18. const INITIAL_STATE = {
  19. /**
  20. * The indicator which determines whether the Toolbox is enabled.
  21. *
  22. * @type {boolean}
  23. */
  24. enabled: true,
  25. /**
  26. * The indicator which determines whether the hangup menu is visible.
  27. *
  28. * @type {boolean}
  29. */
  30. hangupMenuVisible: false,
  31. /**
  32. * The indicator which determines whether a Toolbar in the Toolbox is
  33. * hovered.
  34. *
  35. * @type {boolean}
  36. */
  37. hovered: false,
  38. /**
  39. * The indicator which determines whether the overflow menu(s) are to be displayed as drawers.
  40. *
  41. * @type {boolean}
  42. */
  43. overflowDrawer: false,
  44. /**
  45. * The indicator which determines whether the OverflowMenu is visible.
  46. *
  47. * @type {boolean}
  48. */
  49. overflowMenuVisible: false,
  50. /**
  51. * A number, non-zero value which identifies the timer created by a call
  52. * to setTimeout().
  53. *
  54. * @type {number|null}
  55. */
  56. timeoutID: null,
  57. /**
  58. * The indicator that determines whether the Toolbox is visible.
  59. *
  60. * @type {boolean}
  61. */
  62. visible: false
  63. };
  64. ReducerRegistry.register(
  65. 'features/toolbox',
  66. (state: Object = INITIAL_STATE, action: Object) => {
  67. switch (action.type) {
  68. case CLEAR_TOOLBOX_TIMEOUT:
  69. return {
  70. ...state,
  71. timeoutID: undefined
  72. };
  73. case FULL_SCREEN_CHANGED:
  74. return {
  75. ...state,
  76. fullScreen: action.fullScreen
  77. };
  78. case SET_HANGUP_MENU_VISIBLE:
  79. return {
  80. ...state,
  81. hangupMenuVisible: action.visible
  82. };
  83. case SET_OVERFLOW_DRAWER:
  84. return {
  85. ...state,
  86. overflowDrawer: action.displayAsDrawer
  87. };
  88. case SET_OVERFLOW_MENU_VISIBLE:
  89. return {
  90. ...state,
  91. overflowMenuVisible: action.visible
  92. };
  93. case SET_TOOLBAR_HOVERED:
  94. return {
  95. ...state,
  96. hovered: action.hovered
  97. };
  98. case SET_TOOLBOX_ENABLED:
  99. return {
  100. ...state,
  101. enabled: action.enabled
  102. };
  103. case SET_TOOLBOX_TIMEOUT:
  104. return {
  105. ...state,
  106. timeoutID: action.timeoutID
  107. };
  108. case SET_TOOLBOX_VISIBLE:
  109. return set(state, 'visible', action.visible);
  110. case TOGGLE_TOOLBOX_VISIBLE:
  111. return set(state, 'visible', !state.visible);
  112. }
  113. return state;
  114. });