Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

reducer.ts 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import { set } from '../base/redux/functions';
  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. export interface IToolboxState {
  65. enabled: boolean;
  66. fullScreen?: boolean;
  67. hangupMenuVisible: boolean;
  68. hovered: boolean;
  69. overflowDrawer: boolean;
  70. overflowMenuVisible: boolean;
  71. timeoutID?: number | null;
  72. visible: boolean;
  73. }
  74. ReducerRegistry.register<IToolboxState>(
  75. 'features/toolbox',
  76. (state = INITIAL_STATE, action): IToolboxState => {
  77. switch (action.type) {
  78. case CLEAR_TOOLBOX_TIMEOUT:
  79. return {
  80. ...state,
  81. timeoutID: undefined
  82. };
  83. case FULL_SCREEN_CHANGED:
  84. return {
  85. ...state,
  86. fullScreen: action.fullScreen
  87. };
  88. case SET_HANGUP_MENU_VISIBLE:
  89. return {
  90. ...state,
  91. hangupMenuVisible: action.visible
  92. };
  93. case SET_OVERFLOW_DRAWER:
  94. return {
  95. ...state,
  96. overflowDrawer: action.displayAsDrawer
  97. };
  98. case SET_OVERFLOW_MENU_VISIBLE:
  99. return {
  100. ...state,
  101. overflowMenuVisible: action.visible
  102. };
  103. case SET_TOOLBAR_HOVERED:
  104. return {
  105. ...state,
  106. hovered: action.hovered
  107. };
  108. case SET_TOOLBOX_ENABLED:
  109. return {
  110. ...state,
  111. enabled: action.enabled
  112. };
  113. case SET_TOOLBOX_TIMEOUT:
  114. return {
  115. ...state,
  116. timeoutID: action.timeoutID
  117. };
  118. case SET_TOOLBOX_VISIBLE:
  119. return set(state, 'visible', action.visible);
  120. case TOGGLE_TOOLBOX_VISIBLE:
  121. return set(state, 'visible', !state.visible);
  122. }
  123. return state;
  124. });