您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.web.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. } from './actions.native';
  15. declare var interfaceConfig: Object;
  16. export * from './actions.native';
  17. /**
  18. * Docks/undocks the Toolbox.
  19. *
  20. * @param {boolean} dock - True if dock, false otherwise.
  21. * @returns {Function}
  22. */
  23. export function dockToolbox(dock: boolean): Function {
  24. return (dispatch: Dispatch<any>, getState: Function) => {
  25. const { timeoutMS, visible } = getState()['features/toolbox'];
  26. if (dock) {
  27. // First make sure the toolbox is shown.
  28. visible || dispatch(showToolbox());
  29. dispatch(clearToolboxTimeout());
  30. } else if (visible) {
  31. dispatch(
  32. setToolboxTimeout(
  33. () => dispatch(hideToolbox()),
  34. timeoutMS));
  35. } else {
  36. dispatch(showToolbox());
  37. }
  38. };
  39. }
  40. /**
  41. * Signals that full screen mode has been entered or exited.
  42. *
  43. * @param {boolean} fullScreen - Whether or not full screen mode is currently
  44. * enabled.
  45. * @returns {{
  46. * type: FULL_SCREEN_CHANGED,
  47. * fullScreen: boolean
  48. * }}
  49. */
  50. export function fullScreenChanged(fullScreen: boolean) {
  51. return {
  52. type: FULL_SCREEN_CHANGED,
  53. fullScreen
  54. };
  55. }
  56. /**
  57. * Hides the toolbox.
  58. *
  59. * @param {boolean} force - True to force the hiding of the toolbox without
  60. * caring about the extended toolbar side panels.
  61. * @returns {Function}
  62. */
  63. export function hideToolbox(force: boolean = false): Function {
  64. return (dispatch: Dispatch<any>, getState: Function) => {
  65. const state = getState();
  66. const {
  67. alwaysVisible,
  68. hovered,
  69. timeoutMS
  70. } = state['features/toolbox'];
  71. if (alwaysVisible) {
  72. return;
  73. }
  74. dispatch(clearToolboxTimeout());
  75. const focusSelector = '.toolbox-content-items:focus-within,.filmstrip:focus-within,.remotevideomenu:hover';
  76. if (!force
  77. && (hovered
  78. || state['features/invite'].calleeInfoVisible
  79. || state['features/chat'].isOpen
  80. || document.querySelector(focusSelector))) {
  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<any>, getState: Function) => {
  113. const state = getState();
  114. const {
  115. alwaysVisible,
  116. enabled,
  117. timeoutMS,
  118. visible,
  119. overflowDrawer
  120. } = state['features/toolbox'];
  121. const { contextMenuOpened } = state['features/base/responsive-ui'];
  122. const contextMenuOpenedInTileview = isLayoutTileView(state) && contextMenuOpened && !overflowDrawer;
  123. if (enabled && !visible && !contextMenuOpenedInTileview) {
  124. dispatch(setToolboxVisible(true));
  125. // If the Toolbox is always visible, there's no need for a timeout
  126. // to toggle its visibility.
  127. if (!alwaysVisible) {
  128. dispatch(
  129. setToolboxTimeout(
  130. () => dispatch(hideToolbox()),
  131. timeout || timeoutMS));
  132. dispatch(setToolboxTimeoutMS(interfaceConfig.TOOLBAR_TIMEOUT));
  133. }
  134. }
  135. };
  136. }
  137. /**
  138. * Signals a request to display overflow as drawer.
  139. *
  140. * @param {boolean} displayAsDrawer - True to display overflow as drawer, false to preserve original behaviour.
  141. * @returns {{
  142. * type: SET_OVERFLOW_DRAWER,
  143. * displayAsDrawer: boolean
  144. * }}
  145. */
  146. export function setOverflowDrawer(displayAsDrawer: boolean) {
  147. return {
  148. type: SET_OVERFLOW_DRAWER,
  149. displayAsDrawer
  150. };
  151. }
  152. /**
  153. * Disables and hides the toolbox on demand when in tile view.
  154. *
  155. * @returns {void}
  156. */
  157. export function hideToolboxOnTileView() {
  158. return (dispatch: Dispatch<any>, getState: Function) => {
  159. const state = getState();
  160. const { overflowDrawer } = state['features/toolbox'];
  161. if (!overflowDrawer && isLayoutTileView(state)) {
  162. dispatch(hideToolbox(true));
  163. }
  164. };
  165. }