123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import React from 'react';
- import { Text, TouchableHighlight, View } from 'react-native';
-
- import { translate } from '../../../base/i18n';
- import { Icon, IconCloseLarge } from '../../../base/icons';
- import { connect } from '../../../base/redux';
- import {
- setParams
- } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
- import { setLobbyChatActiveState, setPrivateMessageRecipient } from '../../actions.any';
- import AbstractMessageRecipient, {
- type Props as AbstractProps
- } from '../AbstractMessageRecipient';
-
- import styles from './styles';
-
-
- type Props = AbstractProps & {
-
- /**
- * The Redux dispatch function.
- */
- dispatch: Function,
-
- /**
- * Is lobby messaging active.
- */
- isLobbyChatActive: boolean,
-
- /**
- * The participant string for lobby chat messaging.
- */
- lobbyMessageRecipient: Object,
-
- /**
- * The participant object set for private messaging.
- */
- privateMessageRecipient: Object,
- };
-
- /**
- * Class to implement the displaying of the recipient of the next message.
- */
- class MessageRecipient extends AbstractMessageRecipient<Props> {
-
- /**
- * Constructor of the component.
- *
- * @param {Props} props - The props of the component.
- */
- constructor(props: Props) {
- super(props);
-
- this._onResetPrivateMessageRecipient = this._onResetPrivateMessageRecipient.bind(this);
- this._onResetLobbyMessageRecipient = this._onResetLobbyMessageRecipient.bind(this);
- }
-
- _onResetLobbyMessageRecipient: () => void;
-
- /**
- * Resets lobby message recipient from state.
- *
- * @returns {void}
- */
- _onResetLobbyMessageRecipient() {
- const { dispatch } = this.props;
-
- dispatch(setLobbyChatActiveState(false));
- }
-
- _onResetPrivateMessageRecipient: () => void;
-
- /**
- * Resets private message recipient from state.
- *
- * @returns {void}
- */
- _onResetPrivateMessageRecipient() {
- const { dispatch } = this.props;
-
- dispatch(setPrivateMessageRecipient());
-
- setParams({
- privateMessageRecipient: undefined
- });
- }
-
- /**
- * Implements {@code PureComponent#render}.
- *
- * @inheritdoc
- * @returns {ReactElement}
- */
- render() {
- const {
- isLobbyChatActive,
- lobbyMessageRecipient,
- privateMessageRecipient,
- t
- } = this.props;
-
- if (isLobbyChatActive) {
- return (
- <View style = { styles.lobbyMessageRecipientContainer }>
- <Text style = { styles.messageRecipientText }>
- { t('chat.lobbyChatMessageTo', {
- recipient: lobbyMessageRecipient.name
- }) }
- </Text>
- <TouchableHighlight
- onPress = { this._onResetLobbyMessageRecipient }>
- <Icon
- src = { IconCloseLarge }
- style = { styles.messageRecipientCancelIcon } />
- </TouchableHighlight>
- </View>
- );
- }
-
- if (!privateMessageRecipient) {
- return null;
- }
-
- return (
- <View style = { styles.messageRecipientContainer }>
- <Text style = { styles.messageRecipientText }>
- { t('chat.messageTo', {
- recipient: privateMessageRecipient.name
- }) }
- </Text>
- <TouchableHighlight
- onPress = { this._onResetPrivateMessageRecipient }
- underlayColor = { 'transparent' }>
- <Icon
- src = { IconCloseLarge }
- style = { styles.messageRecipientCancelIcon } />
- </TouchableHighlight>
- </View>
- );
- }
- }
-
- /**
- * Maps part of the redux state to the props of this component.
- *
- * @param {Object} state - The Redux state.
- * @returns {Props}
- */
- function _mapStateToProps(state) {
- const { lobbyMessageRecipient, isLobbyChatActive } = state['features/chat'];
-
- return {
- isLobbyChatActive,
- lobbyMessageRecipient
- };
- }
-
- export default translate(connect(_mapStateToProps)(MessageRecipient));
|