Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

MessageRecipient.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import React from 'react';
  2. import { Text, TouchableHighlight, View } from 'react-native';
  3. import { translate } from '../../../base/i18n';
  4. import { Icon, IconCloseLarge } from '../../../base/icons';
  5. import { connect } from '../../../base/redux';
  6. import {
  7. setParams
  8. } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
  9. import { setLobbyChatActiveState, setPrivateMessageRecipient } from '../../actions.any';
  10. import AbstractMessageRecipient, {
  11. type Props as AbstractProps
  12. } from '../AbstractMessageRecipient';
  13. import styles from './styles';
  14. type Props = AbstractProps & {
  15. /**
  16. * The Redux dispatch function.
  17. */
  18. dispatch: Function,
  19. /**
  20. * Is lobby messaging active.
  21. */
  22. isLobbyChatActive: boolean,
  23. /**
  24. * The participant string for lobby chat messaging.
  25. */
  26. lobbyMessageRecipient: Object,
  27. /**
  28. * The participant object set for private messaging.
  29. */
  30. privateMessageRecipient: Object,
  31. };
  32. /**
  33. * Class to implement the displaying of the recipient of the next message.
  34. */
  35. class MessageRecipient extends AbstractMessageRecipient<Props> {
  36. /**
  37. * Constructor of the component.
  38. *
  39. * @param {Props} props - The props of the component.
  40. */
  41. constructor(props: Props) {
  42. super(props);
  43. this._onResetPrivateMessageRecipient = this._onResetPrivateMessageRecipient.bind(this);
  44. this._onResetLobbyMessageRecipient = this._onResetLobbyMessageRecipient.bind(this);
  45. }
  46. _onResetLobbyMessageRecipient: () => void;
  47. /**
  48. * Resets lobby message recipient from state.
  49. *
  50. * @returns {void}
  51. */
  52. _onResetLobbyMessageRecipient() {
  53. const { dispatch } = this.props;
  54. dispatch(setLobbyChatActiveState(false));
  55. }
  56. _onResetPrivateMessageRecipient: () => void;
  57. /**
  58. * Resets private message recipient from state.
  59. *
  60. * @returns {void}
  61. */
  62. _onResetPrivateMessageRecipient() {
  63. const { dispatch } = this.props;
  64. dispatch(setPrivateMessageRecipient());
  65. setParams({
  66. privateMessageRecipient: undefined
  67. });
  68. }
  69. /**
  70. * Implements {@code PureComponent#render}.
  71. *
  72. * @inheritdoc
  73. * @returns {ReactElement}
  74. */
  75. render() {
  76. const {
  77. isLobbyChatActive,
  78. lobbyMessageRecipient,
  79. privateMessageRecipient,
  80. t
  81. } = this.props;
  82. if (isLobbyChatActive) {
  83. return (
  84. <View style = { styles.lobbyMessageRecipientContainer }>
  85. <Text style = { styles.messageRecipientText }>
  86. { t('chat.lobbyChatMessageTo', {
  87. recipient: lobbyMessageRecipient.name
  88. }) }
  89. </Text>
  90. <TouchableHighlight
  91. onPress = { this._onResetLobbyMessageRecipient }>
  92. <Icon
  93. src = { IconCloseLarge }
  94. style = { styles.messageRecipientCancelIcon } />
  95. </TouchableHighlight>
  96. </View>
  97. );
  98. }
  99. if (!privateMessageRecipient) {
  100. return null;
  101. }
  102. return (
  103. <View style = { styles.messageRecipientContainer }>
  104. <Text style = { styles.messageRecipientText }>
  105. { t('chat.messageTo', {
  106. recipient: privateMessageRecipient.name
  107. }) }
  108. </Text>
  109. <TouchableHighlight
  110. onPress = { this._onResetPrivateMessageRecipient }
  111. underlayColor = { 'transparent' }>
  112. <Icon
  113. src = { IconCloseLarge }
  114. style = { styles.messageRecipientCancelIcon } />
  115. </TouchableHighlight>
  116. </View>
  117. );
  118. }
  119. }
  120. /**
  121. * Maps part of the redux state to the props of this component.
  122. *
  123. * @param {Object} state - The Redux state.
  124. * @returns {Props}
  125. */
  126. function _mapStateToProps(state) {
  127. const { lobbyMessageRecipient, isLobbyChatActive } = state['features/chat'];
  128. return {
  129. isLobbyChatActive,
  130. lobbyMessageRecipient
  131. };
  132. }
  133. export default translate(connect(_mapStateToProps)(MessageRecipient));