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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import {
  4. FULL_SCREEN_CHANGED,
  5. SET_FULL_SCREEN,
  6. SET_OVERFLOW_DRAWER
  7. } from './actionTypes';
  8. import {
  9. clearToolboxTimeout,
  10. setToolboxTimeout,
  11. setToolboxTimeoutMS,
  12. setToolboxVisible
  13. } from './actions.native';
  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<any>, getState: Function) => {
  24. const { timeoutMS, visible } = getState()['features/toolbox'];
  25. if (dock) {
  26. // First make sure the toolbox is shown.
  27. visible || dispatch(showToolbox());
  28. dispatch(clearToolboxTimeout());
  29. } else if (visible) {
  30. dispatch(
  31. setToolboxTimeout(
  32. () => dispatch(hideToolbox()),
  33. timeoutMS));
  34. } else {
  35. dispatch(showToolbox());
  36. }
  37. };
  38. }
  39. /**
  40. * Signals that full screen mode has been entered or exited.
  41. *
  42. * @param {boolean} fullScreen - Whether or not full screen mode is currently
  43. * enabled.
  44. * @returns {{
  45. * type: FULL_SCREEN_CHANGED,
  46. * fullScreen: boolean
  47. * }}
  48. */
  49. export function fullScreenChanged(fullScreen: boolean) {
  50. return {
  51. type: FULL_SCREEN_CHANGED,
  52. fullScreen
  53. };
  54. }
  55. /**
  56. * Hides the toolbox.
  57. *
  58. * @param {boolean} force - True to force the hiding of the toolbox without
  59. * caring about the extended toolbar side panels.
  60. * @returns {Function}
  61. */
  62. export function hideToolbox(force: boolean = false): Function {
  63. return (dispatch: Dispatch<any>, getState: Function) => {
  64. const state = getState();
  65. const {
  66. alwaysVisible,
  67. hovered,
  68. timeoutMS
  69. } = state['features/toolbox'];
  70. if (alwaysVisible) {
  71. return;
  72. }
  73. dispatch(clearToolboxTimeout());
  74. const focusSelector = '.toolbox-content-items:focus-within,.filmstrip:focus-within,.remotevideomenu:hover';
  75. if (!force
  76. && (hovered
  77. || state['features/invite'].calleeInfoVisible
  78. || state['features/chat'].isOpen
  79. || document.querySelector(focusSelector))) {
  80. dispatch(
  81. setToolboxTimeout(
  82. () => dispatch(hideToolbox()),
  83. timeoutMS));
  84. } else {
  85. dispatch(setToolboxVisible(false));
  86. }
  87. };
  88. }
  89. /**
  90. * Signals a request to enter or exit full screen mode.
  91. *
  92. * @param {boolean} fullScreen - True to enter full screen mode, false to exit.
  93. * @returns {{
  94. * type: SET_FULL_SCREEN,
  95. * fullScreen: boolean
  96. * }}
  97. */
  98. export function setFullScreen(fullScreen: boolean) {
  99. return {
  100. type: SET_FULL_SCREEN,
  101. fullScreen
  102. };
  103. }
  104. /**
  105. * Shows the toolbox for specified timeout.
  106. *
  107. * @param {number} timeout - Timeout for showing the toolbox.
  108. * @returns {Function}
  109. */
  110. export function showToolbox(timeout: number = 0): Object {
  111. return (dispatch: Dispatch<any>, getState: Function) => {
  112. const state = getState();
  113. const {
  114. alwaysVisible,
  115. enabled,
  116. timeoutMS,
  117. visible
  118. } = state['features/toolbox'];
  119. if (enabled && !visible) {
  120. dispatch(setToolboxVisible(true));
  121. // If the Toolbox is always visible, there's no need for a timeout
  122. // to toggle its visibility.
  123. if (!alwaysVisible) {
  124. dispatch(
  125. setToolboxTimeout(
  126. () => dispatch(hideToolbox()),
  127. timeout || timeoutMS));
  128. dispatch(setToolboxTimeoutMS(interfaceConfig.TOOLBAR_TIMEOUT));
  129. }
  130. }
  131. };
  132. }
  133. /**
  134. * Signals a request to display overflow as drawer.
  135. *
  136. * @param {boolean} displayAsDrawer - True to display overflow as drawer, false to preserve original behaviour.
  137. * @returns {{
  138. * type: SET_OVERFLOW_DRAWER,
  139. * displayAsDrawer: boolean
  140. * }}
  141. */
  142. export function setOverflowDrawer(displayAsDrawer: boolean) {
  143. return {
  144. type: SET_OVERFLOW_DRAWER,
  145. displayAsDrawer
  146. };
  147. }