您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AbstractChatMessage.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // @flow
  2. import { PureComponent } from 'react';
  3. import { getAvatarURLByParticipantId } from '../../base/participants';
  4. /**
  5. * The type of the React {@code Component} props of {@code AbstractChatMessage}.
  6. */
  7. export type Props = {
  8. /**
  9. * The URL of the avatar of the participant.
  10. */
  11. _avatarURL: string,
  12. /**
  13. * The representation of a chat message.
  14. */
  15. message: Object,
  16. /**
  17. * Whether or not the name of the participant which sent the message should
  18. * be displayed.
  19. */
  20. showDisplayName: boolean,
  21. /**
  22. * Invoked to receive translated strings.
  23. */
  24. t: Function
  25. };
  26. /**
  27. * Abstract component to display a chat message.
  28. */
  29. export default class AbstractChatMessage<P: Props> extends PureComponent<P> {
  30. static defaultProps = {
  31. showDisplayName: true
  32. };
  33. }
  34. /**
  35. * Maps part of the Redux state to the props of this component.
  36. *
  37. * @param {Object} state - The Redux state.
  38. * @param {Props} ownProps - The own props of the component.
  39. * @returns {{
  40. * _avatarURL: string
  41. * }}
  42. */
  43. export function _mapStateToProps(state: Object, ownProps: Props) {
  44. const { message } = ownProps;
  45. return {
  46. _avatarURL: getAvatarURLByParticipantId(state, message.id)
  47. };
  48. }