This commit is contained in:
10
react/features/base/audio-only/actionTypes.ts
Normal file
10
react/features/base/audio-only/actionTypes.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* The type of (redux) action which sets the audio-only flag for the current
|
||||
* conference.
|
||||
*
|
||||
* {
|
||||
* type: SET_AUDIO_ONLY,
|
||||
* audioOnly: boolean
|
||||
* }
|
||||
*/
|
||||
export const SET_AUDIO_ONLY = 'SET_AUDIO_ONLY';
|
||||
51
react/features/base/audio-only/actions.ts
Normal file
51
react/features/base/audio-only/actions.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { createAudioOnlyChangedEvent } from '../../analytics/AnalyticsEvents';
|
||||
import { sendAnalytics } from '../../analytics/functions';
|
||||
import { IStore } from '../../app/types';
|
||||
|
||||
import { SET_AUDIO_ONLY } from './actionTypes';
|
||||
import logger from './logger';
|
||||
|
||||
|
||||
/**
|
||||
* Sets the audio-only flag for the current JitsiConference.
|
||||
*
|
||||
* @param {boolean} audioOnly - True if the conference should be audio only; false, otherwise.
|
||||
* @returns {{
|
||||
* type: SET_AUDIO_ONLY,
|
||||
* audioOnly: boolean
|
||||
* }}
|
||||
*/
|
||||
export function setAudioOnly(audioOnly: boolean) {
|
||||
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||
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,
|
||||
audioOnly
|
||||
});
|
||||
|
||||
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.conference.onToggleAudioOnly();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the audio-only flag for the current JitsiConference.
|
||||
*
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function toggleAudioOnly() {
|
||||
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||
const { enabled } = getState()['features/base/audio-only'];
|
||||
|
||||
dispatch(setAudioOnly(!enabled));
|
||||
};
|
||||
}
|
||||
3
react/features/base/audio-only/logger.ts
Normal file
3
react/features/base/audio-only/logger.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { getLogger } from '../logging/functions';
|
||||
|
||||
export default getLogger('features/base/audio-only');
|
||||
25
react/features/base/audio-only/reducer.ts
Normal file
25
react/features/base/audio-only/reducer.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import ReducerRegistry from '../redux/ReducerRegistry';
|
||||
|
||||
import { SET_AUDIO_ONLY } from './actionTypes';
|
||||
|
||||
export interface IAudioOnlyState {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_STATE = {
|
||||
enabled: false
|
||||
};
|
||||
|
||||
|
||||
ReducerRegistry.register<IAudioOnlyState>('features/base/audio-only',
|
||||
(state = DEFAULT_STATE, action): IAudioOnlyState => {
|
||||
switch (action.type) {
|
||||
case SET_AUDIO_ONLY:
|
||||
return {
|
||||
...state,
|
||||
enabled: action.audioOnly
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user