You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.ts 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { createAudioOnlyChangedEvent } from '../../analytics/AnalyticsEvents';
  2. import { sendAnalytics } from '../../analytics/functions';
  3. import { IStore } from '../../app/types';
  4. import { SET_AUDIO_ONLY } from './actionTypes';
  5. import logger from './logger';
  6. /**
  7. * Sets the audio-only flag for the current JitsiConference.
  8. *
  9. * @param {boolean} audioOnly - True if the conference should be audio only; false, otherwise.
  10. * @returns {{
  11. * type: SET_AUDIO_ONLY,
  12. * audioOnly: boolean
  13. * }}
  14. */
  15. export function setAudioOnly(audioOnly: boolean) {
  16. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  17. const { enabled: oldValue } = getState()['features/base/audio-only'];
  18. if (oldValue !== audioOnly) {
  19. sendAnalytics(createAudioOnlyChangedEvent(audioOnly));
  20. logger.log(`Audio-only ${audioOnly ? 'enabled' : 'disabled'}`);
  21. dispatch({
  22. type: SET_AUDIO_ONLY,
  23. audioOnly
  24. });
  25. if (typeof APP !== 'undefined') {
  26. // TODO This should be a temporary solution that lasts only until video
  27. // tracks and all ui is moved into react/redux on the web.
  28. APP.conference.onToggleAudioOnly();
  29. }
  30. }
  31. };
  32. }
  33. /**
  34. * Toggles the audio-only flag for the current JitsiConference.
  35. *
  36. * @returns {Function}
  37. */
  38. export function toggleAudioOnly() {
  39. return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
  40. const { enabled } = getState()['features/base/audio-only'];
  41. dispatch(setAudioOnly(!enabled));
  42. };
  43. }