From 2b5ec4a3c076bb1f18eeafbd96b0a80c6b8bfbaa Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 15 Oct 2015 10:44:04 -0400
Subject: Small refactor of websocket code on client and server

---
 web/react/components/msg_typing.jsx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'web/react/components/msg_typing.jsx')

diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx
index 569942390..216cbc7f0 100644
--- a/web/react/components/msg_typing.jsx
+++ b/web/react/components/msg_typing.jsx
@@ -1,8 +1,11 @@
 // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
 // See License.txt for license information.
 
-var SocketStore = require('../stores/socket_store.jsx');
-var UserStore = require('../stores/user_store.jsx');
+const SocketStore = require('../stores/socket_store.jsx');
+const UserStore = require('../stores/user_store.jsx');
+
+const Constants = require('../utils/constants.jsx');
+const SocketEvents = Constants.SocketEvents;
 
 export default class MsgTyping extends React.Component {
     constructor(props) {
@@ -33,7 +36,7 @@ export default class MsgTyping extends React.Component {
     }
 
     onChange(msg) {
-        if (msg.action === 'typing' &&
+        if (msg.action === SocketEvents.TYPING &&
             this.props.channelId === msg.channel_id &&
             this.props.parentId === msg.props.parent_id) {
             this.lastTime = new Date().getTime();
@@ -52,7 +55,7 @@ export default class MsgTyping extends React.Component {
                     }
                 }.bind(this), 3000);
             }
-        } else if (msg.action === 'posted' && msg.channel_id === this.props.channelId) {
+        } else if (msg.action === SocketEvents.POSTED && msg.channel_id === this.props.channelId) {
             this.setState({text: ''});
         }
     }
-- 
cgit v1.2.3-1-g7c22


From 20723437aa607abdfa0e9353927e8bf8694a6b2c Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 15 Oct 2015 10:57:09 -0400
Subject: Fix typing socket constant

---
 web/react/components/msg_typing.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'web/react/components/msg_typing.jsx')

diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx
index 216cbc7f0..1bd23c55c 100644
--- a/web/react/components/msg_typing.jsx
+++ b/web/react/components/msg_typing.jsx
@@ -37,8 +37,8 @@ export default class MsgTyping extends React.Component {
 
     onChange(msg) {
         if (msg.action === SocketEvents.TYPING &&
-            this.props.channelId === msg.channel_id &&
-            this.props.parentId === msg.props.parent_id) {
+                this.props.channelId === msg.channel_id &&
+                this.props.parentId === msg.props.parent_id) {
             this.lastTime = new Date().getTime();
 
             var username = 'Someone';
-- 
cgit v1.2.3-1-g7c22

