選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Chat.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // @flow
  2. import { useIsFocused } from '@react-navigation/native';
  3. import React, { useEffect } from 'react';
  4. import { translate } from '../../../base/i18n';
  5. import JitsiScreen from '../../../base/modal/components/JitsiScreen';
  6. import { connect } from '../../../base/redux';
  7. import { closeChat } from '../../actions.any';
  8. import AbstractChat, {
  9. type Props as AbstractProps,
  10. _mapStateToProps
  11. } from '../AbstractChat';
  12. import ChatInputBar from './ChatInputBar';
  13. import MessageContainer from './MessageContainer';
  14. import MessageRecipient from './MessageRecipient';
  15. import styles from './styles';
  16. type Props = AbstractProps & {
  17. /**
  18. * Is this screen focused or not(React Navigation).
  19. */
  20. isChatScreenFocused: boolean,
  21. /**
  22. * Default prop for navigating between screen components(React Navigation).
  23. */
  24. navigation: Object,
  25. /**
  26. * Default prop for navigating between screen components(React Navigation).
  27. */
  28. route: Object
  29. };
  30. /**
  31. * Implements a React native component that renders the chat window (modal) of
  32. * the mobile client.
  33. */
  34. class Chat extends AbstractChat<Props> {
  35. /**
  36. * Implements React's {@link Component#render()}.
  37. *
  38. * @inheritdoc
  39. */
  40. render() {
  41. const { _messages, route } = this.props;
  42. const privateMessageRecipient = route.params?.privateMessageRecipient;
  43. return (
  44. <JitsiScreen
  45. disableForcedKeyboardDismiss = { true }
  46. hasBottomTextInput = { true }
  47. hasTabNavigator = { true }
  48. style = { styles.chatContainer }>
  49. <MessageContainer messages = { _messages } />
  50. <MessageRecipient privateMessageRecipient = { privateMessageRecipient } />
  51. <ChatInputBar onSend = { this._onSendMessage } />
  52. </JitsiScreen>
  53. );
  54. }
  55. _onSendMessage: (string) => void;
  56. }
  57. export default translate(connect(_mapStateToProps)(props => {
  58. const {
  59. _nbUnreadMessages,
  60. navigation,
  61. t
  62. } = props;
  63. const isChatScreenFocused = useIsFocused();
  64. const nrUnreadMessages
  65. = !isChatScreenFocused && _nbUnreadMessages > 0
  66. ? `(${_nbUnreadMessages})` : '';
  67. useEffect(() => {
  68. navigation.setOptions({
  69. tabBarLabel: `${t('chat.tabs.chat')} ${nrUnreadMessages}`
  70. });
  71. return () => props.dispatch(closeChat());
  72. }, [ nrUnreadMessages ]);
  73. return (
  74. <Chat
  75. { ...props }
  76. isChatScreenFocused = { isChatScreenFocused } />
  77. );
  78. }));