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.

actions.web.js 4.7KB

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