Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

actions.any.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import UIEvents from '../../../service/UI/UIEvents';
  4. import { VIDEO_MUTE, createToolbarEvent, sendAnalytics } from '../analytics';
  5. import { setAudioOnly } from '../base/audio-only';
  6. import { VIDEO_MUTISM_AUTHORITY, setVideoMuted } from '../base/media';
  7. import { getLocalVideoType } from '../base/tracks';
  8. import {
  9. SET_TOOLBOX_ENABLED,
  10. SET_TOOLBOX_VISIBLE,
  11. TOGGLE_TOOLBOX_VISIBLE
  12. } from './actionTypes';
  13. declare var APP: Object;
  14. /**
  15. * Enables/disables the toolbox.
  16. *
  17. * @param {boolean} enabled - True to enable the toolbox or false to disable it.
  18. * @returns {{
  19. * type: SET_TOOLBOX_ENABLED,
  20. * enabled: boolean
  21. * }}
  22. */
  23. export function setToolboxEnabled(enabled: boolean): Object {
  24. return {
  25. type: SET_TOOLBOX_ENABLED,
  26. enabled
  27. };
  28. }
  29. /**
  30. * Shows/hides the toolbox.
  31. *
  32. * @param {boolean} visible - True to show the toolbox or false to hide it.
  33. * @returns {Function}
  34. */
  35. export function setToolboxVisible(visible: boolean): Object {
  36. return (dispatch: Dispatch<any>, getState: Function) => {
  37. const { toolbarConfig: { alwaysVisible } } = getState()['features/base/config'];
  38. if (!visible && alwaysVisible) {
  39. return;
  40. }
  41. dispatch({
  42. type: SET_TOOLBOX_VISIBLE,
  43. visible
  44. });
  45. };
  46. }
  47. /**
  48. * Action to toggle the toolbox visibility.
  49. *
  50. * @returns {Function}
  51. */
  52. export function toggleToolboxVisible() {
  53. return (dispatch: Dispatch<any>, getState: Function) => {
  54. const state = getState();
  55. const { toolbarConfig: { alwaysVisible } } = state['features/base/config'];
  56. const { visible } = state['features/toolbox'];
  57. if (visible && alwaysVisible) {
  58. return;
  59. }
  60. dispatch({
  61. type: TOGGLE_TOOLBOX_VISIBLE
  62. });
  63. };
  64. }
  65. /**
  66. * Action to handle toggle video from toolbox's video buttons.
  67. *
  68. * @param {boolean} muted - Whether to mute or unmute.
  69. * @param {boolean} showUI - When set to false will not display any error.
  70. * @param {boolean} ensureTrack - True if we want to ensure that a new track is
  71. * created if missing.
  72. * @returns {Function}
  73. */
  74. export function handleToggleVideoMuted(muted, showUI, ensureTrack) {
  75. return (dispatch: Dispatch<any>, getState: Function) => {
  76. const state = getState();
  77. const { enabled: audioOnly } = state['features/base/audio-only'];
  78. const tracks = state['features/base/tracks'];
  79. sendAnalytics(createToolbarEvent(VIDEO_MUTE, { enable: muted }));
  80. if (audioOnly) {
  81. dispatch(setAudioOnly(false));
  82. }
  83. const mediaType = getLocalVideoType(tracks);
  84. dispatch(
  85. setVideoMuted(
  86. muted,
  87. mediaType,
  88. VIDEO_MUTISM_AUTHORITY.USER,
  89. ensureTrack));
  90. // FIXME: The old conference logic still relies on this event being
  91. // emitted.
  92. typeof APP === 'undefined'
  93. || APP.UI.emitEvent(UIEvents.VIDEO_MUTED, muted, showUI);
  94. };
  95. }