bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/chat/message-form/container.jsx

42 lines
1.3 KiB
React
Raw Normal View History

import React from 'react';
import { throttle } from '/imports/utils/throttle';
import { makeCall } from '/imports/ui/services/api';
2021-05-18 04:25:07 +08:00
import MessageForm from './component';
import ChatService from '/imports/ui/components/chat/service';
import ChatMessageFormContainer from '../chat-graphql/chat-message-form/component';
2021-09-11 04:48:52 +08:00
import { layoutSelect } from '../../layout/context';
const CHAT_CONFIG = Meteor.settings.public.chat;
const START_TYPING_THROTTLE_INTERVAL = 2000;
2021-05-18 04:25:07 +08:00
const MessageFormContainer = (props) => {
2021-09-11 04:48:52 +08:00
const idChatOpen = layoutSelect((i) => i.idChatOpen);
2021-05-18 04:25:07 +08:00
const handleSendMessage = (message) => {
ChatService.setUserSentMessage(true);
2021-05-18 04:25:07 +08:00
return ChatService.sendGroupMessage(message, idChatOpen);
};
const startUserTyping = throttle(
2021-08-09 22:24:02 +08:00
(chatId) => makeCall('startUserTyping', chatId),
2021-05-18 04:25:07 +08:00
START_TYPING_THROTTLE_INTERVAL,
);
const stopUserTyping = () => makeCall('stopUserTyping');
2021-05-18 04:25:07 +08:00
return (
<MessageForm
{...{
startUserTyping,
stopUserTyping,
UnsentMessagesCollection: ChatService.UnsentMessagesCollection,
minMessageLength: CHAT_CONFIG.min_message_length,
maxMessageLength: CHAT_CONFIG.max_message_length,
handleSendMessage,
idChatOpen,
...props,
}}
/>
);
};
export default ChatMessageFormContainer;