2019-08-09 02:53:08 +08:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2021-01-22 00:05:41 +08:00
|
|
|
import _ from 'lodash';
|
2019-08-22 05:56:32 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2019-08-09 02:53:08 +08:00
|
|
|
import ChatForm from './component';
|
|
|
|
import ChatService from '../service';
|
|
|
|
|
|
|
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
2019-08-22 05:56:32 +08:00
|
|
|
|
2019-08-09 02:53:08 +08:00
|
|
|
class ChatContainer extends PureComponent {
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<ChatForm {...this.props} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default withTracker(() => {
|
|
|
|
const cleanScrollAndSendMessage = (message) => {
|
|
|
|
ChatService.updateScrollPosition(null);
|
|
|
|
return ChatService.sendGroupMessage(message);
|
|
|
|
};
|
2019-08-22 05:56:32 +08:00
|
|
|
|
|
|
|
const startUserTyping = chatId => makeCall('startUserTyping', chatId);
|
|
|
|
|
|
|
|
const stopUserTyping = () => makeCall('stopUserTyping');
|
|
|
|
|
2019-08-09 02:53:08 +08:00
|
|
|
return {
|
2021-01-22 00:05:41 +08:00
|
|
|
startUserTyping: _.throttle(startUserTyping, 2000),
|
2019-08-22 05:56:32 +08:00
|
|
|
stopUserTyping,
|
2019-08-09 02:53:08 +08:00
|
|
|
UnsentMessagesCollection: ChatService.UnsentMessagesCollection,
|
|
|
|
minMessageLength: CHAT_CONFIG.min_message_length,
|
|
|
|
maxMessageLength: CHAT_CONFIG.max_message_length,
|
|
|
|
handleSendMessage: cleanScrollAndSendMessage,
|
|
|
|
};
|
|
|
|
})(ChatContainer);
|