2017-05-01 23:04:12 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
|
|
|
import { appNavigate } from '../app';
|
2017-08-18 11:30:30 +00:00
|
|
|
import { MEDIA_TYPE } from '../base/media';
|
|
|
|
import { isLocalTrackMuted } from '../base/tracks';
|
2017-05-01 23:04:12 +00:00
|
|
|
|
|
|
|
/**
|
2017-07-19 21:25:06 +00:00
|
|
|
* Maps redux actions to {@link Toolbox} (React {@code Component}) props.
|
2017-05-01 23:04:12 +00:00
|
|
|
*
|
2017-07-19 21:25:06 +00:00
|
|
|
* @param {Function} dispatch - The redux {@code dispatch} function.
|
2017-05-01 23:04:12 +00:00
|
|
|
* @returns {{
|
|
|
|
* _onHangup: Function,
|
|
|
|
* _onToggleAudio: Function,
|
|
|
|
* _onToggleVideo: Function
|
|
|
|
* }}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
export function abstractMapDispatchToProps(dispatch: Dispatch<*>): Object {
|
|
|
|
return {
|
2017-08-04 21:06:42 +00:00
|
|
|
// Inject {@code dispatch} into the React Component's props in case it
|
|
|
|
// needs to dispatch an action in the redux store without
|
|
|
|
// {@code mapDispatchToProps}.
|
|
|
|
dispatch,
|
|
|
|
|
2017-05-01 23:04:12 +00:00
|
|
|
/**
|
|
|
|
* Dispatches action to leave the current conference.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
_onHangup() {
|
|
|
|
// XXX We don't know here which value is effectively/internally
|
|
|
|
// used when there's no valid room name to join. It isn't our
|
|
|
|
// business to know that anyway. The undefined value is our
|
|
|
|
// expression of (1) the lack of knowledge & (2) the desire to no
|
|
|
|
// longer have a valid room name to join.
|
2017-07-17 15:33:49 +00:00
|
|
|
dispatch(appNavigate(undefined));
|
2017-05-01 23:04:12 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-07-19 21:25:06 +00:00
|
|
|
* Maps parts of the redux state to {@link Toolbox} (React {@code Component})
|
|
|
|
* props.
|
2017-05-01 23:04:12 +00:00
|
|
|
*
|
2017-07-19 21:25:06 +00:00
|
|
|
* @param {Object} state - The redux state of which parts are to be mapped to
|
|
|
|
* {@code Toolbox} props.
|
2017-05-01 23:04:12 +00:00
|
|
|
* @protected
|
|
|
|
* @returns {{
|
|
|
|
* _audioMuted: boolean,
|
|
|
|
* _videoMuted: boolean,
|
|
|
|
* _visible: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function abstractMapStateToProps(state: Object): Object {
|
2017-07-19 12:38:38 +00:00
|
|
|
const tracks = state['features/base/tracks'];
|
2017-05-01 23:04:12 +00:00
|
|
|
const { visible } = state['features/toolbox'];
|
|
|
|
|
|
|
|
return {
|
|
|
|
/**
|
2017-07-19 21:25:06 +00:00
|
|
|
* Flag showing whether audio is muted.
|
2017-05-01 23:04:12 +00:00
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2017-08-18 11:30:30 +00:00
|
|
|
_audioMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO),
|
2017-05-01 23:04:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag showing whether video is muted.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2017-08-18 11:30:30 +00:00
|
|
|
_videoMuted: isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO),
|
2017-05-01 23:04:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag showing whether toolbox is visible.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
_visible: visible
|
|
|
|
};
|
|
|
|
}
|
2017-05-26 21:28:16 +00:00
|
|
|
|
|
|
|
/**
|
2017-07-19 21:25:06 +00:00
|
|
|
* Returns the button object corresponding to a specific {@code buttonName}.
|
2017-05-26 21:28:16 +00:00
|
|
|
*
|
|
|
|
* @param {string} buttonName - The name of the button.
|
|
|
|
* @param {Object} state - The current state.
|
|
|
|
* @returns {Object} - The button object.
|
|
|
|
*/
|
|
|
|
export function getButton(buttonName: string, state: Object) {
|
|
|
|
const { primaryToolbarButtons, secondaryToolbarButtons }
|
|
|
|
= state['features/toolbox'];
|
|
|
|
|
|
|
|
return primaryToolbarButtons.get(buttonName)
|
|
|
|
|| secondaryToolbarButtons.get(buttonName);
|
|
|
|
}
|