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.ts 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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_BUTTONS_WITH_NOTIFY_CLICK,
  7. SET_HANGUP_MENU_VISIBLE,
  8. SET_OVERFLOW_DRAWER,
  9. SET_OVERFLOW_MENU_VISIBLE,
  10. SET_PARTICIPANT_MENU_BUTTONS_WITH_NOTIFY_CLICK,
  11. SET_TOOLBAR_BUTTONS,
  12. SET_TOOLBAR_HOVERED,
  13. SET_TOOLBOX_ENABLED,
  14. SET_TOOLBOX_SHIFT_UP,
  15. SET_TOOLBOX_TIMEOUT,
  16. SET_TOOLBOX_VISIBLE,
  17. TOGGLE_TOOLBOX_VISIBLE
  18. } from './actionTypes';
  19. import { NOTIFY_CLICK_MODE } from './types';
  20. /**
  21. * Initial state of toolbox's part of Redux store.
  22. */
  23. const INITIAL_STATE = {
  24. buttonsWithNotifyClick: new Map(),
  25. /**
  26. * The indicator which determines whether the Toolbox is enabled.
  27. *
  28. * @type {boolean}
  29. */
  30. enabled: true,
  31. /**
  32. * The indicator which determines whether the hangup menu is visible.
  33. *
  34. * @type {boolean}
  35. */
  36. hangupMenuVisible: false,
  37. /**
  38. * The indicator which determines whether a Toolbar in the Toolbox is
  39. * hovered.
  40. *
  41. * @type {boolean}
  42. */
  43. hovered: false,
  44. participantMenuButtonsWithNotifyClick: new Map(),
  45. /**
  46. * The indicator which determines whether the overflow menu(s) are to be displayed as drawers.
  47. *
  48. * @type {boolean}
  49. */
  50. overflowDrawer: false,
  51. /**
  52. * The indicator which determines whether the OverflowMenu is visible.
  53. *
  54. * @type {boolean}
  55. */
  56. overflowMenuVisible: false,
  57. /**
  58. * Whether to shift the toolbar up (in case it overlaps the tiles names).
  59. */
  60. shiftUp: false,
  61. /**
  62. * A number, non-zero value which identifies the timer created by a call
  63. * to setTimeout().
  64. *
  65. * @type {number|null}
  66. */
  67. timeoutID: null,
  68. /**
  69. * The list of enabled toolbar buttons.
  70. *
  71. * @type {Array<string>}
  72. */
  73. toolbarButtons: [],
  74. /**
  75. * The indicator that determines whether the Toolbox is visible.
  76. *
  77. * @type {boolean}
  78. */
  79. visible: false
  80. };
  81. export interface IToolboxState {
  82. buttonsWithNotifyClick: Map<string, NOTIFY_CLICK_MODE>;
  83. enabled: boolean;
  84. fullScreen?: boolean;
  85. hangupMenuVisible: boolean;
  86. hovered: boolean;
  87. overflowDrawer: boolean;
  88. overflowMenuVisible: boolean;
  89. participantMenuButtonsWithNotifyClick: Map<string, NOTIFY_CLICK_MODE>;
  90. shiftUp: boolean;
  91. timeoutID?: number | null;
  92. toolbarButtons: Array<string>;
  93. visible: boolean;
  94. }
  95. ReducerRegistry.register<IToolboxState>(
  96. 'features/toolbox',
  97. (state = INITIAL_STATE, action): IToolboxState => {
  98. switch (action.type) {
  99. case CLEAR_TOOLBOX_TIMEOUT:
  100. return {
  101. ...state,
  102. timeoutID: undefined
  103. };
  104. case FULL_SCREEN_CHANGED:
  105. return {
  106. ...state,
  107. fullScreen: action.fullScreen
  108. };
  109. case SET_HANGUP_MENU_VISIBLE:
  110. return {
  111. ...state,
  112. hangupMenuVisible: action.visible
  113. };
  114. case SET_OVERFLOW_DRAWER:
  115. return {
  116. ...state,
  117. overflowDrawer: action.displayAsDrawer
  118. };
  119. case SET_OVERFLOW_MENU_VISIBLE:
  120. return {
  121. ...state,
  122. overflowMenuVisible: action.visible
  123. };
  124. case SET_TOOLBAR_BUTTONS:
  125. return {
  126. ...state,
  127. toolbarButtons: action.toolbarButtons
  128. };
  129. case SET_BUTTONS_WITH_NOTIFY_CLICK:
  130. return {
  131. ...state,
  132. buttonsWithNotifyClick: action.buttonsWithNotifyClick
  133. };
  134. case SET_TOOLBAR_HOVERED:
  135. return {
  136. ...state,
  137. hovered: action.hovered
  138. };
  139. case SET_TOOLBOX_ENABLED:
  140. return {
  141. ...state,
  142. enabled: action.enabled
  143. };
  144. case SET_TOOLBOX_TIMEOUT:
  145. return {
  146. ...state,
  147. timeoutID: action.timeoutID
  148. };
  149. case SET_TOOLBOX_SHIFT_UP:
  150. return {
  151. ...state,
  152. shiftUp: action.shiftUp
  153. };
  154. case SET_TOOLBOX_VISIBLE:
  155. return set(state, 'visible', action.visible);
  156. case SET_PARTICIPANT_MENU_BUTTONS_WITH_NOTIFY_CLICK:
  157. return {
  158. ...state,
  159. participantMenuButtonsWithNotifyClick: action.participantMenuButtonsWithNotifyClick
  160. };
  161. case TOGGLE_TOOLBOX_VISIBLE:
  162. return set(state, 'visible', !state.visible);
  163. }
  164. return state;
  165. });