2021-11-11 12:32:01 +00:00
|
|
|
import { CHAT_ENABLED, getFeatureFlag } from '../../../base/flags';
|
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import { IconMessage, IconReply } from '../../../base/icons';
|
|
|
|
import { getParticipantById } from '../../../base/participants';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2022-05-13 14:46:50 +00:00
|
|
|
import { handleLobbyChatInitialized, openChat } from '../../../chat/actions';
|
2022-01-25 12:55:57 +00:00
|
|
|
import { navigate } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
|
|
|
|
import { screen } from '../../../mobile/navigation/routes';
|
2019-10-07 12:35:04 +00:00
|
|
|
|
|
|
|
export type Props = AbstractButtonProps & {
|
|
|
|
|
2022-03-03 17:29:38 +00:00
|
|
|
/**
|
|
|
|
* The Redux Dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
2019-10-07 12:35:04 +00:00
|
|
|
/**
|
|
|
|
* The ID of the participant that the message is to be sent.
|
|
|
|
*/
|
|
|
|
participantID: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the button is rendered as a reply button.
|
|
|
|
*/
|
|
|
|
reply: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to be used to translate i18n labels.
|
|
|
|
*/
|
|
|
|
t: Function,
|
|
|
|
|
2021-10-20 19:29:21 +00:00
|
|
|
/**
|
|
|
|
* True if the polls feature is disabled.
|
|
|
|
*/
|
|
|
|
_isPollsDisabled: boolean,
|
|
|
|
|
2022-03-03 17:29:38 +00:00
|
|
|
/**
|
|
|
|
* True if message is a lobby chat message.
|
|
|
|
*/
|
|
|
|
_isLobbyMessage: boolean,
|
|
|
|
|
2019-10-07 12:35:04 +00:00
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* The participant object retrieved from Redux.
|
2019-10-07 12:35:04 +00:00
|
|
|
*/
|
2021-02-12 11:18:16 +00:00
|
|
|
_participant: Object,
|
2019-10-07 12:35:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class to render a button that initiates the sending of a private message through chet.
|
|
|
|
*/
|
|
|
|
class PrivateMessageButton extends AbstractButton<Props, any> {
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.privateMessage';
|
|
|
|
icon = IconMessage;
|
|
|
|
label = 'toolbar.privateMessage';
|
|
|
|
toggledIcon = IconReply;
|
|
|
|
|
|
|
|
/**
|
2022-05-10 15:28:23 +00:00
|
|
|
* Handles clicking / pressing the button.
|
2019-10-07 12:35:04 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClick() {
|
2022-03-03 17:29:38 +00:00
|
|
|
if (this.props._isLobbyMessage) {
|
|
|
|
this.props.dispatch(handleLobbyChatInitialized(this.props.participantID));
|
|
|
|
}
|
2022-05-10 15:28:23 +00:00
|
|
|
|
2022-05-13 14:46:50 +00:00
|
|
|
this.props.dispatch(openChat(this.props._participant));
|
|
|
|
|
2021-10-20 19:29:21 +00:00
|
|
|
this.props._isPollsDisabled
|
|
|
|
? navigate(screen.conference.chat, {
|
|
|
|
privateMessageRecipient: this.props._participant
|
|
|
|
})
|
|
|
|
: navigate(screen.conference.chatandpolls.main, {
|
|
|
|
screen: screen.conference.chatandpolls.tab.chat,
|
|
|
|
params: {
|
|
|
|
privateMessageRecipient: this.props._participant
|
|
|
|
}
|
|
|
|
});
|
2019-10-07 12:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to be implemented by subclasses, which must return a
|
|
|
|
* {@code boolean} value indicating if this button is toggled or not.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_isToggled() {
|
|
|
|
return this.props.reply;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux store to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @param {Props} ownProps - The own props of the component.
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-11-18 12:46:54 +00:00
|
|
|
export function _mapStateToProps(state: Object, ownProps: Props) {
|
2021-03-12 07:34:31 +00:00
|
|
|
const enabled = getFeatureFlag(state, CHAT_ENABLED, true);
|
2021-10-20 19:29:21 +00:00
|
|
|
const { disablePolls } = state['features/base/config'];
|
2022-05-10 15:28:23 +00:00
|
|
|
const { visible = enabled, isLobbyMessage, participantID } = ownProps;
|
2021-03-12 07:34:31 +00:00
|
|
|
|
2019-10-07 12:35:04 +00:00
|
|
|
return {
|
2021-10-20 19:29:21 +00:00
|
|
|
_isPollsDisabled: disablePolls,
|
2022-05-10 15:28:23 +00:00
|
|
|
_participant: getParticipantById(state, participantID),
|
2022-03-03 17:29:38 +00:00
|
|
|
_isLobbyMessage: isLobbyMessage,
|
2021-03-12 07:34:31 +00:00
|
|
|
visible
|
2019-10-07 12:35:04 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-02-12 11:18:16 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(PrivateMessageButton));
|