Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ChatButton.js 2.2KB

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