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.

AbstractMessageRecipient.ts 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { PureComponent } from 'react';
  2. import { WithTranslation } from 'react-i18next';
  3. import { IReduxState } from '../../app/types';
  4. import { getParticipantDisplayName, isLocalParticipantModerator } from '../../base/participants/functions';
  5. import { setLobbyChatActiveState } from '../actions.any';
  6. import { setPrivateMessageRecipient } from '../actions.web';
  7. export interface IProps extends WithTranslation {
  8. /**
  9. * Is lobby messaging active.
  10. */
  11. _isLobbyChatActive: boolean;
  12. /**
  13. * The name of the lobby message recipient, if any.
  14. */
  15. _lobbyMessageRecipient?: string;
  16. /**
  17. * Function to make the lobby message recipient inactive.
  18. */
  19. _onHideLobbyChatRecipient: () => void;
  20. /**
  21. * Function to remove the recipient setting of the chat window.
  22. */
  23. _onRemovePrivateMessageRecipient: () => void;
  24. /**
  25. * The name of the message recipient, if any.
  26. */
  27. _privateMessageRecipient?: string;
  28. /**
  29. * Shows widget if it is necessary.
  30. */
  31. _visible: boolean;
  32. classes?: any;
  33. }
  34. /**
  35. * Abstract class for the {@code MessageRecipient} component.
  36. */
  37. export default class AbstractMessageRecipient<P extends IProps> extends PureComponent<P> {
  38. }
  39. /**
  40. * Maps part of the props of this component to Redux actions.
  41. *
  42. * @param {Function} dispatch - The Redux dispatch function.
  43. * @returns {IProps}
  44. */
  45. export function _mapDispatchToProps(dispatch: Function) {
  46. return {
  47. _onRemovePrivateMessageRecipient: () => {
  48. dispatch(setPrivateMessageRecipient());
  49. },
  50. _onHideLobbyChatRecipient: () => {
  51. dispatch(setLobbyChatActiveState(false));
  52. }
  53. };
  54. }
  55. /**
  56. * Maps part of the Redux store to the props of this component.
  57. *
  58. * @param {Object} state - The Redux state.
  59. * @returns {IProps}
  60. */
  61. export function _mapStateToProps(state: IReduxState) {
  62. const { privateMessageRecipient, lobbyMessageRecipient, isLobbyChatActive } = state['features/chat'];
  63. return {
  64. _privateMessageRecipient:
  65. privateMessageRecipient ? getParticipantDisplayName(state, privateMessageRecipient.id) : undefined,
  66. _isLobbyChatActive: isLobbyChatActive,
  67. _lobbyMessageRecipient:
  68. isLobbyChatActive && lobbyMessageRecipient ? lobbyMessageRecipient.name : undefined,
  69. _visible: isLobbyChatActive ? isLocalParticipantModerator(state) : true
  70. };
  71. }