2022-08-04 08:51:33 +00:00
|
|
|
// @ts-ignore
|
2020-05-20 10:57:03 +00:00
|
|
|
import UIEvents from '../../../../service/UI/UIEvents';
|
2022-09-07 08:20:05 +00:00
|
|
|
import { createAudioOnlyChangedEvent } from '../../analytics/AnalyticsEvents';
|
|
|
|
import { sendAnalytics } from '../../analytics/functions';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { IStore } from '../../app/types';
|
2019-07-31 12:47:52 +00:00
|
|
|
|
|
|
|
import { SET_AUDIO_ONLY } from './actionTypes';
|
2019-08-21 14:50:00 +00:00
|
|
|
import logger from './logger';
|
2019-07-31 12:47:52 +00:00
|
|
|
|
|
|
|
|
2022-08-04 08:51:33 +00:00
|
|
|
declare let APP: any;
|
2019-07-31 12:47:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the audio-only flag for the current JitsiConference.
|
|
|
|
*
|
2022-08-25 12:40:32 +00:00
|
|
|
* @param {boolean} audioOnly - True if the conference should be audio only; false, otherwise.
|
2019-07-31 12:47:52 +00:00
|
|
|
* @returns {{
|
|
|
|
* type: SET_AUDIO_ONLY,
|
2022-08-25 12:40:32 +00:00
|
|
|
* audioOnly: boolean
|
2019-07-31 12:47:52 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2022-08-25 12:40:32 +00:00
|
|
|
export function setAudioOnly(audioOnly: boolean) {
|
2022-10-11 10:47:54 +00:00
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2019-07-31 12:47:52 +00:00
|
|
|
const { enabled: oldValue } = getState()['features/base/audio-only'];
|
|
|
|
|
|
|
|
if (oldValue !== audioOnly) {
|
|
|
|
sendAnalytics(createAudioOnlyChangedEvent(audioOnly));
|
|
|
|
logger.log(`Audio-only ${audioOnly ? 'enabled' : 'disabled'}`);
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SET_AUDIO_ONLY,
|
2022-08-25 12:40:32 +00:00
|
|
|
audioOnly
|
2019-07-31 12:47:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (typeof APP !== 'undefined') {
|
|
|
|
// TODO This should be a temporary solution that lasts only until video
|
|
|
|
// tracks and all ui is moved into react/redux on the web.
|
|
|
|
APP.UI.emitEvent(UIEvents.TOGGLE_AUDIO_ONLY, audioOnly);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles the audio-only flag for the current JitsiConference.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function toggleAudioOnly() {
|
2022-10-11 10:47:54 +00:00
|
|
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2019-07-31 12:47:52 +00:00
|
|
|
const { enabled } = getState()['features/base/audio-only'];
|
|
|
|
|
2022-08-25 12:40:32 +00:00
|
|
|
return dispatch(setAudioOnly(!enabled));
|
2019-07-31 12:47:52 +00:00
|
|
|
};
|
|
|
|
}
|