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.

AbstractMessageRecipient.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // @flow
  2. import { PureComponent } from 'react';
  3. import { getParticipantDisplayName } from '../../base/participants';
  4. import { setPrivateMessageRecipient } from '../actions';
  5. export type Props = {
  6. /**
  7. * Function used to translate i18n labels.
  8. */
  9. t: Function,
  10. /**
  11. * Function to remove the recipent setting of the chat window.
  12. */
  13. _onRemovePrivateMessageRecipient: Function,
  14. /**
  15. * The name of the message recipient, if any.
  16. */
  17. _privateMessageRecipient: ?string
  18. };
  19. /**
  20. * Abstract class for the {@code MessageRecipient} component.
  21. */
  22. export default class AbstractMessageRecipient<P: Props> extends PureComponent<P> {
  23. }
  24. /**
  25. * Maps part of the props of this component to Redux actions.
  26. *
  27. * @param {Function} dispatch - The Redux dispatch function.
  28. * @returns {Props}
  29. */
  30. export function _mapDispatchToProps(dispatch: Function): $Shape<Props> {
  31. return {
  32. _onRemovePrivateMessageRecipient: () => {
  33. dispatch(setPrivateMessageRecipient());
  34. }
  35. };
  36. }
  37. /**
  38. * Maps part of the Redux store to the props of this component.
  39. *
  40. * @param {Object} state - The Redux state.
  41. * @returns {Props}
  42. */
  43. export function _mapStateToProps(state: Object): $Shape<Props> {
  44. const { privateMessageRecipient } = state['features/chat'];
  45. return {
  46. _privateMessageRecipient:
  47. privateMessageRecipient ? getParticipantDisplayName(state, privateMessageRecipient.id) : undefined
  48. };
  49. }