Skip to content
Snippets Groups Projects
Commit 5607ed40 authored by Ramon Souza's avatar Ramon Souza
Browse files

disable user typing notifications when feature is disabled

parent 075c0421
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,8 @@ const messages = defineMessages({ ...@@ -68,7 +68,8 @@ const messages = defineMessages({
}, },
}); });
const CHAT_ENABLED = Meteor.settings.public.chat.enabled; const CHAT_CONFIG = Meteor.settings.public.chat;
const CHAT_ENABLED = CHAT_CONFIG.enabled;
class MessageForm extends PureComponent { class MessageForm extends PureComponent {
constructor(props) { constructor(props) {
...@@ -87,6 +88,7 @@ class MessageForm extends PureComponent { ...@@ -87,6 +88,7 @@ class MessageForm extends PureComponent {
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.setMessageHint = this.setMessageHint.bind(this); this.setMessageHint = this.setMessageHint.bind(this);
this.handleUserTyping = _.throttle(this.handleUserTyping.bind(this), 2000, { trailing: false }); this.handleUserTyping = _.throttle(this.handleUserTyping.bind(this), 2000, { trailing: false });
this.typingIndicator = CHAT_CONFIG.typingIndicator.enabled;
} }
componentDidMount() { componentDidMount() {
...@@ -197,7 +199,7 @@ class MessageForm extends PureComponent { ...@@ -197,7 +199,7 @@ class MessageForm extends PureComponent {
handleUserTyping(error) { handleUserTyping(error) {
const { startUserTyping, chatId } = this.props; const { startUserTyping, chatId } = this.props;
if (error) return; if (error || !this.typingIndicator) return;
startUserTyping(chatId); startUserTyping(chatId);
} }
...@@ -250,12 +252,14 @@ class MessageForm extends PureComponent { ...@@ -250,12 +252,14 @@ class MessageForm extends PureComponent {
div.appendChild(document.createTextNode(msg)); div.appendChild(document.createTextNode(msg));
msg = div.innerHTML; msg = div.innerHTML;
const callback = this.typingIndicator ? stopUserTyping : null;
return ( return (
handleSendMessage(msg), handleSendMessage(msg),
this.setState({ this.setState({
message: '', message: '',
hasErrors: false, hasErrors: false,
}, stopUserTyping) }, callback)
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment