2020-06-12 10:15:16 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2022-09-27 07:10:28 +00:00
|
|
|
import { VIDEO_SHARE_BUTTON_ENABLED, getFeatureFlag } from '../../../base/flags';
|
2021-03-03 14:37:38 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconPlay } from '../../../base/icons';
|
2021-03-03 14:37:38 +00:00
|
|
|
import { getLocalParticipant } from '../../../base/participants';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
|
|
|
import { toggleSharedVideo } from '../../actions.native';
|
|
|
|
import { isSharingStatus } from '../../functions';
|
2020-06-12 10:15:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link TileViewButton}.
|
|
|
|
*/
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the button is disabled.
|
|
|
|
*/
|
|
|
|
_isDisabled: boolean,
|
|
|
|
|
|
|
|
/**
|
2021-03-03 14:37:38 +00:00
|
|
|
* Whether or not the local participant is sharing a video.
|
2020-06-12 10:15:16 +00:00
|
|
|
*/
|
|
|
|
_sharingVideo: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Dispatch<any>
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that renders a toolbar button for toggling the tile layout view.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments AbstractButton
|
2020-06-12 10:15:16 +00:00
|
|
|
*/
|
|
|
|
class VideoShareButton extends AbstractButton<Props, *> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.sharedvideo';
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = IconPlay;
|
2020-06-12 10:15:16 +00:00
|
|
|
label = 'toolbar.sharedvideo';
|
|
|
|
toggledLabel = 'toolbar.stopSharedVideo';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
|
|
|
this._doToggleSharedVideo();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props._sharingVideo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether this button is disabled or not.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isDisabled() {
|
|
|
|
return this.props._isDisabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-03 14:37:38 +00:00
|
|
|
* Dispatches an action to toggle video sharing.
|
2020-06-12 10:15:16 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_doToggleSharedVideo() {
|
|
|
|
this.props.dispatch(toggleSharedVideo());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
2020-07-15 08:48:56 +00:00
|
|
|
* @param {Object} ownProps - The properties explicitly passed to the component instance.
|
2020-06-12 10:15:16 +00:00
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2020-07-15 08:48:56 +00:00
|
|
|
function _mapStateToProps(state, ownProps): Object {
|
2021-03-03 14:37:38 +00:00
|
|
|
const { ownerId, status: sharedVideoStatus } = state['features/shared-video'];
|
2020-06-12 10:15:16 +00:00
|
|
|
const localParticipantId = getLocalParticipant(state).id;
|
2020-07-15 08:48:56 +00:00
|
|
|
const enabled = getFeatureFlag(state, VIDEO_SHARE_BUTTON_ENABLED, true);
|
|
|
|
const { visible = enabled } = ownProps;
|
2020-06-12 10:15:16 +00:00
|
|
|
|
|
|
|
if (ownerId !== localParticipantId) {
|
|
|
|
return {
|
|
|
|
_isDisabled: isSharingStatus(sharedVideoStatus),
|
2020-07-15 08:48:56 +00:00
|
|
|
_sharingVideo: false,
|
2021-03-03 14:37:38 +00:00
|
|
|
visible
|
|
|
|
};
|
2020-06-12 10:15:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2021-03-03 14:37:38 +00:00
|
|
|
_isDisabled: false,
|
2020-07-15 08:48:56 +00:00
|
|
|
_sharingVideo: isSharingStatus(sharedVideoStatus),
|
|
|
|
visible
|
2020-06-12 10:15:16 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(VideoShareButton));
|