2018-04-13 13:03:12 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-05-22 10:01:58 +00:00
|
|
|
import _ from 'lodash';
|
2018-04-13 13:03:12 +00:00
|
|
|
|
2018-05-10 23:01:55 +00:00
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
2022-08-26 18:25:04 +00:00
|
|
|
import { leaveConference } from '../../base/conference/actions';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractHangupButton } from '../../base/toolbox/components';
|
|
|
|
import type { AbstractButtonProps } from '../../base/toolbox/components';
|
2018-04-13 13:03:12 +00:00
|
|
|
|
2018-05-11 02:10:26 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link HangupButton}.
|
|
|
|
*/
|
2018-04-13 13:03:12 +00:00
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
|
|
|
dispatch: Function
|
2018-05-11 02:10:26 +00:00
|
|
|
};
|
2018-04-13 13:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that renders a toolbar button for leaving the current conference.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments AbstractHangupButton
|
2018-04-13 13:03:12 +00:00
|
|
|
*/
|
|
|
|
class HangupButton extends AbstractHangupButton<Props, *> {
|
2019-05-22 10:01:58 +00:00
|
|
|
_hangup: Function;
|
|
|
|
|
2018-06-07 20:32:18 +00:00
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.hangup';
|
2018-04-13 13:03:12 +00:00
|
|
|
label = 'toolbar.hangup';
|
|
|
|
tooltip = 'toolbar.hangup';
|
|
|
|
|
2019-05-22 10:01:58 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new HangupButton instance.
|
|
|
|
*
|
|
|
|
* @param {Props} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._hangup = _.once(() => {
|
|
|
|
sendAnalytics(createToolbarEvent('hangup'));
|
2022-08-26 18:25:04 +00:00
|
|
|
this.props.dispatch(leaveConference());
|
2019-05-22 10:01:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-04-13 13:03:12 +00:00
|
|
|
/**
|
|
|
|
* Helper function to perform the actual hangup action.
|
|
|
|
*
|
|
|
|
* @override
|
2018-05-11 02:10:26 +00:00
|
|
|
* @protected
|
2018-04-13 13:03:12 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_doHangup() {
|
2019-05-22 10:01:58 +00:00
|
|
|
this._hangup();
|
2018-04-13 13:03:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect()(HangupButton));
|