Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ChatButton.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import { CHAT_ENABLED, getFeatureFlag } from '../../../base/flags';
  3. import { IconChat, IconChatUnread } from '../../../base/icons';
  4. import { connect } from '../../../base/redux';
  5. import {
  6. AbstractButton,
  7. type AbstractButtonProps
  8. } from '../../../base/toolbox/components';
  9. import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
  10. import { screen } from '../../../mobile/navigation/routes';
  11. import { getUnreadCount } from '../../functions';
  12. type Props = AbstractButtonProps & {
  13. /**
  14. * True if the polls feature is disabled.
  15. */
  16. _isPollsDisabled: boolean,
  17. /**
  18. * The unread message count.
  19. */
  20. _unreadMessageCount: number
  21. };
  22. /**
  23. * Implements an {@link AbstractButton} to open the chat screen on mobile.
  24. */
  25. class ChatButton extends AbstractButton<Props, *> {
  26. accessibilityLabel = 'toolbar.accessibilityLabel.chat';
  27. icon = IconChat;
  28. label = 'toolbar.chat';
  29. toggledIcon = IconChatUnread;
  30. /**
  31. * Handles clicking / pressing the button, and opens the appropriate dialog.
  32. *
  33. * @private
  34. * @returns {void}
  35. */
  36. _handleClick() {
  37. this.props._isPollsDisabled
  38. ? navigate(screen.conference.chat)
  39. : navigate(screen.conference.chatandpolls.main);
  40. }
  41. /**
  42. * Renders the button toggled when there are unread messages.
  43. *
  44. * @protected
  45. * @returns {boolean}
  46. */
  47. _isToggled() {
  48. return Boolean(this.props._unreadMessageCount);
  49. }
  50. }
  51. /**
  52. * Maps part of the redux state to the component's props.
  53. *
  54. * @param {Object} state - The Redux state.
  55. * @param {Object} ownProps - The properties explicitly passed to the component instance.
  56. * @returns {Props}
  57. */
  58. function _mapStateToProps(state, ownProps) {
  59. const enabled = getFeatureFlag(state, CHAT_ENABLED, true);
  60. const { disablePolls } = state['features/base/config'];
  61. const { visible = enabled } = ownProps;
  62. return {
  63. _isPollsDisabled: disablePolls,
  64. _unreadMessageCount: getUnreadCount(state),
  65. visible
  66. };
  67. }
  68. export default connect(_mapStateToProps)(ChatButton);