Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

actions.web.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* @flow */
  2. import {
  3. clearToolboxTimeout,
  4. setToolboxTimeout,
  5. setToolboxTimeoutMS,
  6. setToolboxVisible
  7. } from './actions.native';
  8. import {
  9. FULL_SCREEN_CHANGED,
  10. SET_FULL_SCREEN
  11. } from './actionTypes';
  12. declare var interfaceConfig: Object;
  13. export * from './actions.native';
  14. /**
  15. * Docks/undocks the Toolbox.
  16. *
  17. * @param {boolean} dock - True if dock, false otherwise.
  18. * @returns {Function}
  19. */
  20. export function dockToolbox(dock: boolean): Function {
  21. return (dispatch: Dispatch<*>, getState: Function) => {
  22. if (interfaceConfig.filmStripOnly) {
  23. return;
  24. }
  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<*>, 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. if (!force
  76. && (hovered
  77. || state['features/invite'].calleeInfoVisible
  78. || state['features/chat'].isOpen)) {
  79. dispatch(
  80. setToolboxTimeout(
  81. () => dispatch(hideToolbox()),
  82. timeoutMS));
  83. } else {
  84. dispatch(setToolboxVisible(false));
  85. }
  86. };
  87. }
  88. /**
  89. * Signals a request to enter or exit full screen mode.
  90. *
  91. * @param {boolean} fullScreen - True to enter full screen mode, false to exit.
  92. * @returns {{
  93. * type: SET_FULL_SCREEN,
  94. * fullScreen: boolean
  95. * }}
  96. */
  97. export function setFullScreen(fullScreen: boolean) {
  98. return {
  99. type: SET_FULL_SCREEN,
  100. fullScreen
  101. };
  102. }
  103. /**
  104. * Shows the toolbox for specified timeout.
  105. *
  106. * @param {number} timeout - Timeout for showing the toolbox.
  107. * @returns {Function}
  108. */
  109. export function showToolbox(timeout: number = 0): Object {
  110. return (dispatch: Dispatch<*>, getState: Function) => {
  111. const state = getState();
  112. const {
  113. alwaysVisible,
  114. enabled,
  115. timeoutMS,
  116. visible
  117. } = state['features/toolbox'];
  118. if (enabled && !visible) {
  119. dispatch(setToolboxVisible(true));
  120. // If the Toolbox is always visible, there's no need for a timeout
  121. // to toggle its visibility.
  122. if (!alwaysVisible) {
  123. dispatch(
  124. setToolboxTimeout(
  125. () => dispatch(hideToolbox()),
  126. timeout || timeoutMS));
  127. dispatch(setToolboxTimeoutMS(interfaceConfig.TOOLBAR_TIMEOUT));
  128. }
  129. }
  130. };
  131. }