2022-08-03 08:41:26 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2021-07-07 08:07:30 +00:00
|
|
|
import React, { Component } from 'react';
|
2022-08-03 08:41:26 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2021-07-07 08:07:30 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2022-08-03 08:41:26 +00:00
|
|
|
// @ts-ignore
|
2021-07-07 08:07:30 +00:00
|
|
|
import { Dialog } from '../../base/dialog';
|
2022-08-03 08:41:26 +00:00
|
|
|
import { translate } from '../../base/i18n/functions';
|
|
|
|
import { connect } from '../../base/redux/functions';
|
2021-07-07 08:07:30 +00:00
|
|
|
import {
|
2022-09-27 07:10:28 +00:00
|
|
|
shouldHideShareAudioHelper,
|
|
|
|
updateSettings
|
2022-08-03 08:41:26 +00:00
|
|
|
// @ts-ignore
|
2021-07-07 08:07:30 +00:00
|
|
|
} from '../../base/settings';
|
2022-08-03 08:41:26 +00:00
|
|
|
// @ts-ignore
|
2021-07-07 08:07:30 +00:00
|
|
|
import { toggleScreensharing } from '../../base/tracks';
|
2022-08-03 08:41:26 +00:00
|
|
|
import Checkbox from '../../base/ui/components/web/Checkbox';
|
2021-07-07 08:07:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link ShareAudioDialog}.
|
|
|
|
*/
|
2022-08-03 08:41:26 +00:00
|
|
|
export interface Props extends WithTranslation {
|
2021-07-07 08:07:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Boolean stored in local storage that determines whether or not the dialog will be displayed again.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
_shouldHideShareAudioHelper: boolean;
|
2021-07-07 08:07:30 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-03 08:41:26 +00:00
|
|
|
* The redux {@code dispatch} function.
|
2021-07-07 08:07:30 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
dispatch: Dispatch<any>;
|
2022-08-03 08:41:26 +00:00
|
|
|
}
|
2021-07-07 08:07:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that displays the audio screen share helper dialog.
|
|
|
|
*/
|
|
|
|
class ShareAudioDialog extends Component<Props> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-08-03 08:41:26 +00:00
|
|
|
constructor(props: Props) {
|
2021-07-07 08:07:30 +00:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onContinue = this._onContinue.bind(this);
|
|
|
|
this._onSelectHideShareAudioHelper = this._onSelectHideShareAudioHelper.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Continue the normal screen sharing flow when the user clicks continue.
|
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_onContinue() {
|
|
|
|
// Pass undefined as the first parameter so the underlying logic decides weather or not to stop screen sharing.
|
|
|
|
this.props.dispatch(toggleScreensharing(undefined, true));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback invoked when the hide audio helper checkbox has been selected. This setting will be persisted in
|
|
|
|
* the local storage, thus the dialog won't be displayed again.
|
|
|
|
*
|
|
|
|
* @param {Object} e - The key event to handle.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2022-08-03 08:41:26 +00:00
|
|
|
_onSelectHideShareAudioHelper({ target: { checked } }: React.ChangeEvent<HTMLInputElement>) {
|
2021-07-07 08:07:30 +00:00
|
|
|
this.props.dispatch(updateSettings({ hideShareAudioHelper: checked }));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements {@Component#render}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const { t } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
|
|
|
hideCancelButton = { false }
|
|
|
|
okKey = { t('dialog.shareAudio') }
|
|
|
|
onSubmit = { this._onContinue }
|
|
|
|
titleKey = { t('dialog.shareAudioTitle') }
|
|
|
|
width = { 'medium' } >
|
|
|
|
<div className = 'share-audio-dialog'>
|
|
|
|
<img
|
|
|
|
className = 'share-audio-animation'
|
|
|
|
src = 'images/share-audio.gif' />
|
|
|
|
<Checkbox
|
2022-08-03 08:41:26 +00:00
|
|
|
checked = { this.props._shouldHideShareAudioHelper }
|
2021-07-07 08:07:30 +00:00
|
|
|
label = { t('dialog.hideShareAudioHelper') }
|
|
|
|
name = 'hide-share-audio-helper'
|
|
|
|
// eslint-disable-next-line react/jsx-no-bind
|
|
|
|
onChange = { this._onSelectHideShareAudioHelper } />
|
|
|
|
</div>
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-08-03 08:41:26 +00:00
|
|
|
function _mapStateToProps(state: Object): Partial<Props> {
|
2021-07-07 08:07:30 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
_shouldHideShareAudioHelper: shouldHideShareAudioHelper(state)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(ShareAudioDialog));
|