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

actions.ts 1.7KB

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