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.

MessageRecipient.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // @flow
  2. import React from 'react';
  3. import { Text, TouchableHighlight, View } from 'react-native';
  4. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  5. import { translate } from '../../../base/i18n';
  6. import { Icon, IconCancelSelection } from '../../../base/icons';
  7. import { connect } from '../../../base/redux';
  8. import { type StyleType } from '../../../base/styles';
  9. import {
  10. setParams
  11. } from '../../../conference/components/native/ConferenceNavigationContainerRef';
  12. import { setPrivateMessageRecipient } from '../../actions.any';
  13. import AbstractMessageRecipient, {
  14. type Props as AbstractProps
  15. } from '../AbstractMessageRecipient';
  16. type Props = AbstractProps & {
  17. /**
  18. * The color-schemed stylesheet of the feature.
  19. */
  20. _styles: StyleType,
  21. /**
  22. * The Redux dispatch function.
  23. */
  24. dispatch: Function,
  25. /**
  26. * The participant object set for private messaging.
  27. */
  28. privateMessageRecipient: Object,
  29. };
  30. /**
  31. * Class to implement the displaying of the recipient of the next message.
  32. */
  33. class MessageRecipient extends AbstractMessageRecipient<Props> {
  34. /**
  35. * Constructor of the component.
  36. *
  37. * @param {Props} props - The props of the component.
  38. */
  39. constructor(props: Props) {
  40. super(props);
  41. this._onResetPrivateMessageRecipient = this._onResetPrivateMessageRecipient.bind(this);
  42. }
  43. _onResetPrivateMessageRecipient: () => void;
  44. /**
  45. * Resets private message recipient from state.
  46. *
  47. * @returns {void}
  48. */
  49. _onResetPrivateMessageRecipient() {
  50. const { dispatch } = this.props;
  51. dispatch(setPrivateMessageRecipient());
  52. setParams({
  53. privateMessageRecipient: undefined
  54. });
  55. }
  56. /**
  57. * Implements {@code PureComponent#render}.
  58. *
  59. * @inheritdoc
  60. * @returns {ReactElement}
  61. */
  62. render() {
  63. const { _styles, privateMessageRecipient, t } = this.props;
  64. if (!privateMessageRecipient) {
  65. return null;
  66. }
  67. return (
  68. <View style = { _styles.messageRecipientContainer }>
  69. <Text style = { _styles.messageRecipientText }>
  70. { t('chat.messageTo', {
  71. recipient: privateMessageRecipient.name
  72. }) }
  73. </Text>
  74. <TouchableHighlight
  75. onPress = { this._onResetPrivateMessageRecipient }>
  76. <Icon
  77. src = { IconCancelSelection }
  78. style = { _styles.messageRecipientCancelIcon } />
  79. </TouchableHighlight>
  80. </View>
  81. );
  82. }
  83. }
  84. /**
  85. * Maps part of the redux state to the props of this component.
  86. *
  87. * @param {Object} state - The Redux state.
  88. * @returns {Props}
  89. */
  90. function _mapStateToProps(state) {
  91. return {
  92. _styles: ColorSchemeRegistry.get(state, 'Chat')
  93. };
  94. }
  95. export default translate(connect(_mapStateToProps)(MessageRecipient));