You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HangupButton.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // @flow
  2. import _ from 'lodash';
  3. import { createToolbarEvent, sendAnalytics } from '../../analytics';
  4. import { appNavigate } from '../../app/actions';
  5. import { disconnect } from '../../base/connection';
  6. import { translate } from '../../base/i18n';
  7. import { connect } from '../../base/redux';
  8. import { AbstractHangupButton } from '../../base/toolbox/components';
  9. import type { AbstractButtonProps } from '../../base/toolbox/components';
  10. /**
  11. * The type of the React {@code Component} props of {@link HangupButton}.
  12. */
  13. type Props = AbstractButtonProps & {
  14. /**
  15. * The redux {@code dispatch} function.
  16. */
  17. dispatch: Function
  18. };
  19. /**
  20. * Component that renders a toolbar button for leaving the current conference.
  21. *
  22. * @extends AbstractHangupButton
  23. */
  24. class HangupButton extends AbstractHangupButton<Props, *> {
  25. _hangup: Function;
  26. accessibilityLabel = 'toolbar.accessibilityLabel.hangup';
  27. label = 'toolbar.hangup';
  28. tooltip = 'toolbar.hangup';
  29. /**
  30. * Initializes a new HangupButton instance.
  31. *
  32. * @param {Props} props - The read-only properties with which the new
  33. * instance is to be initialized.
  34. */
  35. constructor(props: Props) {
  36. super(props);
  37. this._hangup = _.once(() => {
  38. sendAnalytics(createToolbarEvent('hangup'));
  39. // FIXME: these should be unified.
  40. if (navigator.product === 'ReactNative') {
  41. this.props.dispatch(appNavigate(undefined));
  42. } else {
  43. this.props.dispatch(disconnect(true));
  44. }
  45. });
  46. }
  47. /**
  48. * Helper function to perform the actual hangup action.
  49. *
  50. * @override
  51. * @protected
  52. * @returns {void}
  53. */
  54. _doHangup() {
  55. this._hangup();
  56. }
  57. }
  58. export default translate(connect()(HangupButton));