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.

ChatCounter.web.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { getUnreadCount } from '../functions';
  5. /**
  6. * FIXME: Move this UI logic to a generic component that can be used for
  7. * {@code ParticipantCounter} as well.
  8. */
  9. /**
  10. * Implements a React {@link Component} which displays a count of the number of
  11. * unread chat messages.
  12. *
  13. * @extends Component
  14. */
  15. class ChatCounter extends Component {
  16. static propTypes = {
  17. /**
  18. * The number of unread chat messages in the conference.
  19. */
  20. _count: PropTypes.number
  21. };
  22. /**
  23. * Implements React's {@link Component#render()}.
  24. *
  25. * @inheritdoc
  26. * @returns {ReactElement}
  27. */
  28. render() {
  29. return (
  30. <span className = 'badge-round'>
  31. <span>
  32. { this.props._count || null }
  33. </span>
  34. </span>
  35. );
  36. }
  37. }
  38. /**
  39. * Maps (parts of) the Redux state to the associated {@code ChatCounter}'s
  40. * props.
  41. *
  42. * @param {Object} state - The Redux state.
  43. * @private
  44. * @returns {{
  45. * _count: number
  46. * }}
  47. */
  48. function _mapStateToProps(state) {
  49. return {
  50. _count: getUnreadCount(state)
  51. };
  52. }
  53. export default connect(_mapStateToProps)(ChatCounter);