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';
|
2020-06-04 14:09:13 +00:00
|
|
|
import { appNavigate } from '../../app/actions';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { disconnect } from '../../base/connection';
|
|
|
|
import { translate } from '../../base/i18n';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { AbstractHangupButton } from '../../base/toolbox';
|
|
|
|
import type { AbstractButtonProps } from '../../base/toolbox';
|
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.
|
|
|
|
*
|
|
|
|
* @extends AbstractHangupButton
|
|
|
|
*/
|
|
|
|
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'));
|
|
|
|
|
|
|
|
// FIXME: these should be unified.
|
|
|
|
if (navigator.product === 'ReactNative') {
|
|
|
|
this.props.dispatch(appNavigate(undefined));
|
|
|
|
} else {
|
|
|
|
this.props.dispatch(disconnect(true));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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));
|