選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

actions.web.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import {
  4. clearToolboxTimeout,
  5. setToolboxTimeout,
  6. setToolboxTimeoutMS,
  7. setToolboxVisible
  8. } from './actions.native';
  9. import {
  10. FULL_SCREEN_CHANGED,
  11. SET_FULL_SCREEN
  12. } from './actionTypes';
  13. declare var interfaceConfig: Object;
  14. export * from './actions.native';
  15. /**
  16. * Docks/undocks the Toolbox.
  17. *
  18. * @param {boolean} dock - True if dock, false otherwise.
  19. * @returns {Function}
  20. */
  21. export function dockToolbox(dock: boolean): Function {
  22. return (dispatch: Dispatch<any>, getState: Function) => {
  23. if (interfaceConfig.filmStripOnly) {
  24. return;
  25. }
  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. if (!force
  77. && (hovered
  78. || state['features/invite'].calleeInfoVisible
  79. || state['features/chat'].isOpen)) {
  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. }