Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* @flow */
  2. import SideContainerToggler
  3. from '../../../modules/UI/side_pannels/SideContainerToggler';
  4. import {
  5. clearToolboxTimeout,
  6. setToolboxTimeout,
  7. setToolboxTimeoutMS,
  8. setToolboxVisible
  9. } from './actions.native';
  10. import {
  11. FULL_SCREEN_CHANGED,
  12. SET_FULL_SCREEN
  13. } from './actionTypes';
  14. declare var interfaceConfig: Object;
  15. export * from './actions.native';
  16. /**
  17. * Docks/undocks the Toolbox.
  18. *
  19. * @param {boolean} dock - True if dock, false otherwise.
  20. * @returns {Function}
  21. */
  22. export function dockToolbox(dock: boolean): Function {
  23. return (dispatch: Dispatch<*>, getState: Function) => {
  24. if (interfaceConfig.filmStripOnly) {
  25. return;
  26. }
  27. const { timeoutMS, visible } = getState()['features/toolbox'];
  28. if (dock) {
  29. // First make sure the toolbox is shown.
  30. visible || dispatch(showToolbox());
  31. dispatch(clearToolboxTimeout());
  32. } else if (visible) {
  33. dispatch(
  34. setToolboxTimeout(
  35. () => dispatch(hideToolbox()),
  36. timeoutMS));
  37. } else {
  38. dispatch(showToolbox());
  39. }
  40. };
  41. }
  42. /**
  43. * Signals that full screen mode has been entered or exited.
  44. *
  45. * @param {boolean} fullScreen - Whether or not full screen mode is currently
  46. * enabled.
  47. * @returns {{
  48. * type: FULL_SCREEN_CHANGED,
  49. * fullScreen: boolean
  50. * }}
  51. */
  52. export function fullScreenChanged(fullScreen: boolean) {
  53. return {
  54. type: FULL_SCREEN_CHANGED,
  55. fullScreen
  56. };
  57. }
  58. /**
  59. * Hides the toolbox.
  60. *
  61. * @param {boolean} force - True to force the hiding of the toolbox without
  62. * caring about the extended toolbar side panels.
  63. * @returns {Function}
  64. */
  65. export function hideToolbox(force: boolean = false): Function {
  66. return (dispatch: Dispatch<*>, getState: Function) => {
  67. const state = getState();
  68. const {
  69. alwaysVisible,
  70. hovered,
  71. timeoutMS
  72. } = state['features/toolbox'];
  73. if (alwaysVisible) {
  74. return;
  75. }
  76. dispatch(clearToolboxTimeout());
  77. if (!force
  78. && (hovered
  79. || state['features/invite'].calleeInfoVisible
  80. || SideContainerToggler.isVisible())) {
  81. dispatch(
  82. setToolboxTimeout(
  83. () => dispatch(hideToolbox()),
  84. timeoutMS));
  85. } else {
  86. dispatch(setToolboxVisible(false));
  87. }
  88. };
  89. }
  90. /**
  91. * Signals a request to enter or exit full screen mode.
  92. *
  93. * @param {boolean} fullScreen - True to enter full screen mode, false to exit.
  94. * @returns {{
  95. * type: SET_FULL_SCREEN,
  96. * fullScreen: boolean
  97. * }}
  98. */
  99. export function setFullScreen(fullScreen: boolean) {
  100. return {
  101. type: SET_FULL_SCREEN,
  102. fullScreen
  103. };
  104. }
  105. /**
  106. * Shows the toolbox for specified timeout.
  107. *
  108. * @param {number} timeout - Timeout for showing the toolbox.
  109. * @returns {Function}
  110. */
  111. export function showToolbox(timeout: number = 0): Object {
  112. return (dispatch: Dispatch<*>, getState: Function) => {
  113. const state = getState();
  114. const {
  115. alwaysVisible,
  116. enabled,
  117. timeoutMS,
  118. visible
  119. } = state['features/toolbox'];
  120. if (enabled && !visible) {
  121. dispatch(setToolboxVisible(true));
  122. // If the Toolbox is always visible, there's no need for a timeout
  123. // to toggle its visibility.
  124. if (!alwaysVisible) {
  125. dispatch(
  126. setToolboxTimeout(
  127. () => dispatch(hideToolbox()),
  128. timeout || timeoutMS));
  129. dispatch(setToolboxTimeoutMS(interfaceConfig.TOOLBAR_TIMEOUT));
  130. }
  131. }
  132. };
  133. }