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

actions.web.js 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /* @flow */
  2. import Recording from '../../../modules/UI/recording/Recording';
  3. import SideContainerToggler
  4. from '../../../modules/UI/side_pannels/SideContainerToggler';
  5. import UIUtil from '../../../modules/UI/util/UIUtil';
  6. import UIEvents from '../../../service/UI/UIEvents';
  7. import {
  8. clearToolboxTimeout,
  9. setSubjectSlideIn,
  10. setToolbarButton,
  11. setToolboxTimeout,
  12. setToolboxTimeoutMS,
  13. setToolboxVisible,
  14. toggleToolbarButton
  15. } from './actions.native';
  16. export * from './actions.native';
  17. declare var $: Function;
  18. declare var APP: Object;
  19. declare var config: Object;
  20. declare var interfaceConfig: Object;
  21. /**
  22. * Checks whether desktop sharing is enabled and whether
  23. * we have params to start automatically sharing.
  24. *
  25. * @returns {Function}
  26. */
  27. export function checkAutoEnableDesktopSharing(): Function {
  28. return () => {
  29. // XXX Should use dispatcher to toggle screensharing but screensharing
  30. // hasn't been React-ified yet.
  31. if (UIUtil.isButtonEnabled('desktop')
  32. && config.autoEnableDesktopSharing) {
  33. APP.UI.eventEmitter.emit(UIEvents.TOGGLE_SCREENSHARING);
  34. }
  35. };
  36. }
  37. /**
  38. * Docks/undocks the Toolbox.
  39. *
  40. * @param {boolean} dock - True if dock, false otherwise.
  41. * @returns {Function}
  42. */
  43. export function dockToolbox(dock: boolean): Function {
  44. return (dispatch: Dispatch<*>, getState: Function) => {
  45. if (interfaceConfig.filmStripOnly) {
  46. return;
  47. }
  48. const state = getState();
  49. const { timeoutMS, visible } = state['features/toolbox'];
  50. if (dock) {
  51. // First make sure the toolbox is shown.
  52. visible || dispatch(showToolbox());
  53. dispatch(clearToolboxTimeout());
  54. } else if (visible) {
  55. dispatch(
  56. setToolboxTimeout(
  57. () => dispatch(hideToolbox()),
  58. timeoutMS));
  59. } else {
  60. dispatch(showToolbox());
  61. }
  62. };
  63. }
  64. /**
  65. * Hides the toolbox.
  66. *
  67. * @param {boolean} force - True to force the hiding of the toolbox without
  68. * caring about the extended toolbar side panels.
  69. * @returns {Function}
  70. */
  71. export function hideToolbox(force: boolean = false): Function {
  72. return (dispatch: Dispatch<*>, getState: Function) => {
  73. const state = getState();
  74. const {
  75. alwaysVisible,
  76. hovered,
  77. timeoutMS
  78. } = state['features/toolbox'];
  79. if (alwaysVisible) {
  80. return;
  81. }
  82. dispatch(clearToolboxTimeout());
  83. if (!force
  84. && (hovered
  85. || APP.UI.isRingOverlayVisible()
  86. || SideContainerToggler.isVisible())) {
  87. dispatch(
  88. setToolboxTimeout(
  89. () => dispatch(hideToolbox()),
  90. timeoutMS));
  91. } else {
  92. dispatch(setToolboxVisible(false));
  93. dispatch(setSubjectSlideIn(false));
  94. }
  95. };
  96. }
  97. /**
  98. * Signals that unclickable property of profile button should change its value.
  99. *
  100. * @param {boolean} unclickable - Shows whether button is unclickable.
  101. * @returns {Function}
  102. */
  103. export function setProfileButtonUnclickable(unclickable: boolean): Function {
  104. return (dispatch: Dispatch<*>) => {
  105. const buttonName = 'profile';
  106. dispatch(setToolbarButton(buttonName, {
  107. unclickable
  108. }));
  109. UIUtil.removeTooltip(document.getElementById('toolbar_button_profile'));
  110. };
  111. }
  112. /**
  113. * Shows desktop sharing button.
  114. *
  115. * @returns {Function}
  116. */
  117. export function showDesktopSharingButton(): Function {
  118. return (dispatch: Dispatch<*>) => {
  119. const buttonName = 'desktop';
  120. const visible
  121. = APP.conference.isDesktopSharingEnabled
  122. && UIUtil.isButtonEnabled(buttonName);
  123. dispatch(setToolbarButton(buttonName, {
  124. hidden: !visible
  125. }));
  126. };
  127. }
  128. /**
  129. * Shows or hides the dialpad button.
  130. *
  131. * @param {boolean} show - Flag showing whether to show button or not.
  132. * @returns {Function}
  133. */
  134. export function showDialPadButton(show: boolean): Function {
  135. return (dispatch: Dispatch<*>) => {
  136. const buttonName = 'dialpad';
  137. const shouldShow = UIUtil.isButtonEnabled(buttonName) && show;
  138. if (shouldShow) {
  139. dispatch(setToolbarButton(buttonName, {
  140. hidden: false
  141. }));
  142. }
  143. };
  144. }
  145. /**
  146. * Shows recording button.
  147. *
  148. * @returns {Function}
  149. */
  150. export function showRecordingButton(): Function {
  151. return (dispatch: Dispatch<*>) => {
  152. dispatch(setToolbarButton('recording', {
  153. hidden: false
  154. }));
  155. Recording.initRecordingButton();
  156. };
  157. }
  158. /**
  159. * Shows or hides the 'shared video' button.
  160. *
  161. * @returns {Function}
  162. */
  163. export function showSharedVideoButton(): Function {
  164. return (dispatch: Dispatch<*>) => {
  165. const buttonName = 'sharedvideo';
  166. const shouldShow
  167. = UIUtil.isButtonEnabled(buttonName)
  168. && !config.disableThirdPartyRequests;
  169. if (shouldShow) {
  170. dispatch(setToolbarButton(buttonName, {
  171. hidden: false
  172. }));
  173. }
  174. };
  175. }
  176. /**
  177. * Shows SIP call button if it's required and appropriate
  178. * flag is passed.
  179. *
  180. * @param {boolean} show - Flag showing whether to show button or not.
  181. * @returns {Function}
  182. */
  183. export function showSIPCallButton(show: boolean): Function {
  184. return (dispatch: Dispatch<*>) => {
  185. const buttonName = 'sip';
  186. const shouldShow
  187. = APP.conference.sipGatewayEnabled()
  188. && UIUtil.isButtonEnabled(buttonName)
  189. && show;
  190. if (shouldShow) {
  191. dispatch(setToolbarButton(buttonName, {
  192. hidden: !shouldShow
  193. }));
  194. }
  195. };
  196. }
  197. /**
  198. * Shows the toolbox for specified timeout.
  199. *
  200. * @param {number} timeout - Timeout for showing the toolbox.
  201. * @returns {Function}
  202. */
  203. export function showToolbox(timeout: number = 0): Object {
  204. return (dispatch: Dispatch<*>, getState: Function) => {
  205. const state = getState();
  206. const {
  207. alwaysVisible,
  208. enabled,
  209. timeoutMS,
  210. visible
  211. } = state['features/toolbox'];
  212. if (enabled && !visible) {
  213. dispatch(setToolboxVisible(true));
  214. dispatch(setSubjectSlideIn(true));
  215. // If the Toolbox is always visible, there's no need for a timeout
  216. // to toggle its visibility.
  217. if (!alwaysVisible) {
  218. dispatch(
  219. setToolboxTimeout(
  220. () => dispatch(hideToolbox()),
  221. timeout || timeoutMS));
  222. dispatch(setToolboxTimeoutMS(interfaceConfig.TOOLBAR_TIMEOUT));
  223. }
  224. }
  225. };
  226. }
  227. /**
  228. * Event handler for side toolbar container toggled event.
  229. *
  230. * @param {string} containerId - ID of the container.
  231. * @returns {Function}
  232. */
  233. export function toggleSideToolbarContainer(containerId: string): Function {
  234. return (dispatch: Dispatch, getState: Function) => {
  235. const state = getState();
  236. const { secondaryToolbarButtons } = state['features/toolbox'];
  237. for (const key of secondaryToolbarButtons.keys()) {
  238. const isButtonEnabled = UIUtil.isButtonEnabled(key);
  239. const button = secondaryToolbarButtons.get(key);
  240. if (isButtonEnabled
  241. && button.sideContainerId
  242. && button.sideContainerId === containerId) {
  243. dispatch(toggleToolbarButton(key));
  244. break;
  245. }
  246. }
  247. };
  248. }